Changeset 0.37.14 (#226)

Co-authored-by: gobha <jasafpro@gmail.com>
Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
2026-03-23 16:47:48 +00:00
committed by xcaliber
parent fcb998bff9
commit b7746c3004
164 changed files with 6972 additions and 3527 deletions

View File

@@ -338,9 +338,13 @@ func (s *ChannelStore) AddParticipant(ctx context.Context, p *models.ChannelPart
func (s *ChannelStore) ListParticipants(ctx context.Context, channelID string) ([]models.ChannelParticipant, error) {
rows, err := DB.QueryContext(ctx, `
SELECT id, channel_id, participant_type, participant_id, role,
display_name, avatar_url, joined_at
FROM channel_participants WHERE channel_id = ? ORDER BY joined_at`, channelID)
SELECT cp.id, cp.channel_id, cp.participant_type, cp.participant_id, cp.role,
COALESCE(NULLIF(cp.display_name,''), NULLIF(u.display_name,''), u.username) AS display_name,
COALESCE(NULLIF(cp.avatar_url,''), u.avatar_url) AS avatar_url,
cp.joined_at
FROM channel_participants cp
LEFT JOIN users u ON cp.participant_type = 'user' AND cp.participant_id = u.id
WHERE cp.channel_id = ? ORDER BY cp.joined_at`, channelID)
if err != nil {
return nil, err
}
@@ -518,6 +522,32 @@ func (s *ChannelStore) DeleteByOwner(ctx context.Context, channelID, userID stri
return result.RowsAffected()
}
func (s *ChannelStore) ArchiveForRetention(ctx context.Context, channelID string, purgeAfter time.Time) error {
_, err := DB.ExecContext(ctx, `
UPDATE channels SET is_archived = 1, purge_after = ?, updated_at = datetime('now')
WHERE id = ?
`, purgeAfter.UTC().Format("2006-01-02T15:04:05Z"), channelID)
return err
}
func (s *ChannelStore) ListPurgeable(ctx context.Context) ([]string, error) {
rows, err := DB.QueryContext(ctx, `
SELECT id FROM channels WHERE purge_after IS NOT NULL AND purge_after <= datetime('now')
`)
if err != nil {
return nil, err
}
defer rows.Close()
var ids []string
for rows.Next() {
var id string
if rows.Scan(&id) == nil {
ids = append(ids, id)
}
}
return ids, rows.Err()
}
func (s *ChannelStore) MarkRead(ctx context.Context, channelID, userID string) error {
_, err := DB.ExecContext(ctx, `
UPDATE channel_participants