feat(social): show friend presence and require online listening
ci / api / api (push) Successful in 1m11s
ci / db / db (push) Failing after 23s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m29s
ci / ts / ts (packages + web) (push) Successful in 3m15s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 1m27s

This commit is contained in:
mrleo1nid committed 2026-10-23 12:52:00 +03:00
1 parent 582c0dc3d4
commit cd84ceecb2
26 files changed
+574 -400

No files matched your search

+3 -2
View File
@@ -48,7 +48,8 @@ func allowed(ctx context.Context, tx pgx.Tx, a, b uuid.UUID) error {
const personSQL = `SELECT u.id,u.username,COALESCE(u.display_name,u.username::text),
CASE WHEN b.user_id IS NOT NULL THEN 'blocked' WHEN f.accepted THEN 'friend' WHEN f.sender_id=$1 THEN 'outgoing' WHEN f.sender_id IS NOT NULL THEN 'incoming' ELSE 'none' END,
(SELECT count(*) FROM direct_messages m WHERE m.recipient_id=$1 AND m.sender_id=u.id AND m.read_at IS NULL)
(SELECT count(*) FROM direct_messages m WHERE m.recipient_id=$1 AND m.sender_id=u.id AND m.read_at IS NULL),
COALESCE(f.accepted AND b.user_id IS NULL AND u.social_seen_at>now()-interval '45 seconds',false)
FROM users u
LEFT JOIN friendships f ON f.low_id=LEAST($1::uuid,u.id) AND f.high_id=GREATEST($1::uuid,u.id)
LEFT JOIN social_blocks b ON b.user_id=$1 AND b.peer_id=u.id
@@ -60,7 +61,7 @@ func scanPeople(rows pgx.Rows) ([]gen.SocialPerson, error) {
out := []gen.SocialPerson{}
for rows.Next() {
var p gen.SocialPerson
if e := rows.Scan(&p.Id, &p.Username, &p.DisplayName, &p.Relationship, &p.Unread); e != nil {
if e := rows.Scan(&p.Id, &p.Username, &p.DisplayName, &p.Relationship, &p.Unread, &p.Online); e != nil {
return nil, e
}
out = append(out, p)