core: fix postgres channels/relays queries (#6742)

This commit is contained in:
spaced4ndy
2026-04-03 09:24:14 +00:00
committed by GitHub
parent 5241a2d7f3
commit b51c581c19
4 changed files with 20 additions and 12 deletions
+6 -4
View File
@@ -1315,10 +1315,12 @@ getConnectedGroupRelays db GroupInfo {groupId} =
<$> DB.query
db
( groupRelayQuery
<> [sql| JOIN group_members m ON m.group_member_id = gr.group_member_id
WHERE gr.group_id = ?
AND m.member_status = ?
AND gr.relay_status IN (?,?)
<> " "
<> [sql|
JOIN group_members m ON m.group_member_id = gr.group_member_id
WHERE gr.group_id = ?
AND m.member_status = ?
AND gr.relay_status IN (?,?)
|]
)
(groupId, GSMemConnected, RSAccepted, RSActive)
+2 -2
View File
@@ -238,7 +238,7 @@ createNewSndMessage db gVar connOrGroupId chatMsgEvent msgSigning_ encodeMessage
shared_msg_id, shared_msg_id_user, created_at, updated_at
) VALUES (?,?,?,?,?,?,?,?,?,?,?)
|]
((MDSnd, toCMEventTag chatMsgEvent, DB.Binary msgBody, chatBinding <$> signedMsg_, smpEncode . signatures <$> signedMsg_, connId_, groupId_)
((MDSnd, toCMEventTag chatMsgEvent, DB.Binary msgBody, chatBinding <$> signedMsg_, DB.Binary . smpEncode . signatures <$> signedMsg_, connId_, groupId_)
:. (DB.Binary sharedMsgId, Just (BI True), createdAt, createdAt))
msgId <- insertedRowId db
pure $ Right SndMessage {msgId, sharedMsgId = SharedMsgId sharedMsgId, msgBody, signedMsg_}
@@ -325,7 +325,7 @@ createNewRcvMessage db connOrGroupId NewRcvMessage {chatMsgEvent, verifiedMsg, b
shared_msg_id, author_group_member_id, forwarded_by_group_member_id)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
|]
((MDRcv, toCMEventTag chatMsgEvent, DB.Binary msgBody, chatBinding <$> signedMsg_, smpEncode . signatures <$> signedMsg_, brokerTs, currentTs, currentTs, connId_, groupId_)
((MDRcv, toCMEventTag chatMsgEvent, DB.Binary msgBody, chatBinding <$> signedMsg_, DB.Binary . smpEncode . signatures <$> signedMsg_, brokerTs, currentTs, currentTs, connId_, groupId_)
:. (sharedMsgId_, authorMember, forwardedByMember))
msgId <- insertedRowId db
pure RcvMessage {msgId, chatMsgEvent = ACME (encoding @e) chatMsgEvent, sharedMsgId_, msgSigned, forwardedByMember}
@@ -477,7 +477,8 @@ CREATE TABLE test_chat_schema.connections (
quota_err_counter bigint DEFAULT 0 NOT NULL,
short_link_inv bytea,
via_short_link_contact bytea,
via_contact_uri bytea
via_contact_uri bytea,
relay_test smallint DEFAULT 0 NOT NULL
);
@@ -842,7 +843,9 @@ CREATE TABLE test_chat_schema.group_profiles (
description text,
member_admission text,
short_descr text,
group_link bytea
group_type text,
group_link bytea,
public_group_id bytea
);
@@ -865,6 +868,7 @@ CREATE TABLE test_chat_schema.group_relays (
chat_relay_id bigint NOT NULL,
relay_status text NOT NULL,
relay_link bytea,
conf_id bytea,
created_at text DEFAULT now() NOT NULL,
updated_at text DEFAULT now() NOT NULL
);
@@ -948,10 +952,10 @@ CREATE TABLE test_chat_schema.groups (
relay_request_peer_chat_max_version integer,
relay_request_failed smallint DEFAULT 0,
relay_request_err_reason text,
shared_group_id bytea,
root_priv_key bytea,
root_pub_key bytea,
member_priv_key bytea
member_priv_key bytea,
public_member_count bigint
);
+4 -2
View File
@@ -8499,8 +8499,10 @@ prepareChannel2Relays gName owner relay1 relay2 = do
void $ getTermLine owner -- consume group link line
-- second relay connects
owner <## ("#" <> gName <> ": group link relays updated, current relays:")
owner <## " - relay id 1: active"
owner <## " - relay id 2: active"
owner
<### [ " - relay id 1: active",
" - relay id 2: active"
]
owner <## "group link:"
void $ getTermLine owner, -- consume group link line
relay1 <## ("#" <> gName <> ": you joined the group as relay"),