Schema (002_tables.sql): - users: accounts with nick, password hash, timestamps - auth_tokens: per-device tokens with expiry, linked to users - channels: chat rooms with topic and mode flags - channel_members: membership with per-user modes (+o, +v) - messages: channel/DM history with structured JSON meta - message_queue: per-user pending delivery queue - sessions: server-held session state with idle timeout - server_links: federation peer configuration Models (internal/models/): - All models embed Base for database access - Relation methods on models: User.Channels(), User.QueuedMessages(), Channel.Members(), Channel.RecentMessages(), ChannelMember.User(), ChannelMember.Channel(), AuthToken.User(), Session.User() - IDs are UUIDs (TEXT), not auto-increment integers - JSON tags use camelCase per lint rules All tables verified: migrations apply cleanly, 0 lint issues.
21 lines
450 B
Go
21 lines
450 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Message represents a chat message (channel or DM).
|
|
type Message struct {
|
|
Base
|
|
|
|
ID string `json:"id"`
|
|
Timestamp time.Time `json:"ts"`
|
|
FromUserID string `json:"fromUserId"`
|
|
FromNick string `json:"from"`
|
|
Target string `json:"to"`
|
|
Type string `json:"type"`
|
|
Body string `json:"body"`
|
|
Meta string `json:"meta"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
}
|