big update: added reactions, groups, media share
CI / Go (build + vet + test) (push) Canceled after 0s
CI / Web (build + lint) (push) Canceled after 0s

This commit is contained in:
vantablackTea
2026-09-27 21:59:48 +03:00
parent ae24bdd0e0
commit 9d03ea4c51
41 changed files with 2548 additions and 172 deletions
+8 -8
View File
@@ -14,13 +14,13 @@ func (s *Store) CreateDM(ctx context.Context, userA, userB int64) (*Conversation
// Check existing DM
var conv Conversation
err := s.pool.QueryRow(ctx, `
SELECT c.id, c.type, c.created_at
SELECT c.id, c.type, c.name, c.avatar, c.created_at
FROM conversations c
JOIN conversation_members m1 ON m1.conversation_id=c.id AND m1.user_id=$1
JOIN conversation_members m2 ON m2.conversation_id=c.id AND m2.user_id=$2
WHERE c.type='dm'
LIMIT 1
`, userA, userB).Scan(&conv.ID, &conv.Type, &conv.CreatedAt)
`, userA, userB).Scan(&conv.ID, &conv.Type, &conv.Name, &conv.Avatar, &conv.CreatedAt)
if err == nil {
return &conv, nil
}
@@ -42,8 +42,8 @@ func (s *Store) CreateDM(ctx context.Context, userA, userB int64) (*Conversation
err = tx.QueryRow(ctx, `
INSERT INTO conversations(type) VALUES('dm')
RETURNING id, type, created_at
`).Scan(&conv.ID, &conv.Type, &conv.CreatedAt)
RETURNING id, type, name, avatar, created_at
`).Scan(&conv.ID, &conv.Type, &conv.Name, &conv.Avatar, &conv.CreatedAt)
if err != nil {
return nil, err
}
@@ -68,8 +68,8 @@ func (s *Store) CreateDM(ctx context.Context, userA, userB int64) (*Conversation
func (s *Store) GetConversationByID(ctx context.Context, id int64) (*Conversation, error) {
var conv Conversation
err := s.pool.QueryRow(ctx, `
SELECT id, type, created_at FROM conversations WHERE id=$1
`, id).Scan(&conv.ID, &conv.Type, &conv.CreatedAt)
SELECT id, type, name, avatar, created_at FROM conversations WHERE id=$1
`, id).Scan(&conv.ID, &conv.Type, &conv.Name, &conv.Avatar, &conv.CreatedAt)
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrNotFound
@@ -118,7 +118,7 @@ func (s *Store) ConversationIDsForUser(ctx context.Context, userID int64) ([]int
// ListConversationsForUser returns summaries of conversations for a user.
func (s *Store) ListConversationsForUser(ctx context.Context, userID int64) ([]ConversationSummary, error) {
rows, err := s.pool.Query(ctx, `
SELECT c.id, c.type, c.created_at,
SELECT c.id, c.type, c.name, c.avatar, c.created_at,
m.id, m.conversation_id, m.sender_id, m.body, m.created_at, m.edited_at, m.deleted_at,
uc.unread_count
FROM conversation_members cm
@@ -156,7 +156,7 @@ func (s *Store) ListConversationsForUser(ctx context.Context, userID int64) ([]C
msgDeleted *time.Time
)
if err := rows.Scan(
&cs.ID, &cs.Type, &cs.CreatedAt,
&cs.ID, &cs.Type, &cs.Name, &cs.Avatar, &cs.CreatedAt,
&msgID, &msgConvID, &msgSender, &msgBody, &msgCreated, &msgEdited, &msgDeleted,
&cs.UnreadCount,
); err != nil {