bb650ac2a0
Backend: - DB: reactions table, invites table, reply_to column on messages - gateway/events.go: added REACTION_ADD, REACTION_REMOVE events - internal/reaction/handlers.go: reaction CRUD with WebSocket broadcast - internal/invite/handlers.go: invite creation, info, join with code - gateway/hub.go: presence tracking with idle detection - gateway/client.go: idle timeout support Frontend - Social: - TypingIndicator: real-time 'user is typing...' display - ReactionBar: emoji reactions on messages with counts - EmojiPicker: searchable emoji grid for reactions - ReplyBar: quoted reply display above messages - MentionPopup: @mention autocomplete with user list Frontend - PWA: - manifest.json: PWA manifest with theme color and icons - sw.js: service worker with cache-first strategy and push support - stores/push.ts: push notification subscription management - InstallPrompt: 'Add to Home Screen' banner Frontend - Mobile: - MobileNav: bottom nav bar for mobile (servers/channels/chat/members) - MobileDrawer: slide-out drawer with server bar + channel list - index.html: PWA meta tags, safe area viewport Frontend - Polish: - ThemeToggle: dark/light mode switch with localStorage persistence - InviteModal: generate invite links with expiry and max uses - JoinServer: /invite/:code join flow - stores/typing.ts: typing indicator state management - stores/presence.ts: real-time presence tracking - tailwind.config.js: darkMode: 'class', light mode color tokens - styles/index.css: light mode CSS variable overrides
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package gateway
|
|
|
|
import "encoding/json"
|
|
|
|
// Event type constants.
|
|
const (
|
|
EventMessageCreate = "MESSAGE_CREATE"
|
|
EventMessageUpdate = "MESSAGE_UPDATE"
|
|
EventMessageDelete = "MESSAGE_DELETE"
|
|
EventChannelCreate = "CHANNEL_CREATE"
|
|
EventChannelUpdate = "CHANNEL_UPDATE"
|
|
EventChannelDelete = "CHANNEL_DELETE"
|
|
EventMemberAdd = "SERVER_MEMBER_ADD"
|
|
EventMemberRemove = "SERVER_MEMBER_REMOVE"
|
|
EventPresenceUpdate = "PRESENCE_UPDATE"
|
|
EventTypingStart = "TYPING_START"
|
|
EventReactionAdd = "REACTION_ADD"
|
|
EventReactionRemove = "REACTION_REMOVE"
|
|
EventVoiceJoin = "VOICE_JOIN"
|
|
EventVoiceLeave = "VOICE_LEAVE"
|
|
EventVoiceMute = "VOICE_MUTE"
|
|
EventVoiceDeafen = "VOICE_DEAFEN"
|
|
)
|
|
|
|
// Event represents a WebSocket event sent to clients.
|
|
type Event struct {
|
|
Type string `json:"type"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
|
|
// MarshalJSON implements custom JSON marshaling for Event.
|
|
func (e Event) MarshalJSON() ([]byte, error) {
|
|
type eventAlias struct {
|
|
Type string `json:"type"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
return json.Marshal(eventAlias{
|
|
Type: e.Type,
|
|
Data: e.Data,
|
|
})
|
|
}
|
|
|
|
// UnmarshalJSON implements custom JSON unmarshaling for Event.
|
|
func (e *Event) UnmarshalJSON(data []byte) error {
|
|
type eventAlias struct {
|
|
Type string `json:"type"`
|
|
Data json.RawMessage `json:"data,omitempty"`
|
|
}
|
|
var raw eventAlias
|
|
if err := json.Unmarshal(data, &raw); err != nil {
|
|
return err
|
|
}
|
|
e.Type = raw.Type
|
|
e.Data = raw.Data
|
|
return nil
|
|
}
|