This commit is contained in:
spaced4ndy
2025-10-23 13:15:06 +04:00
parent 88e8aa3972
commit 42e9908fb0
2 changed files with 4 additions and 8 deletions

View File

@@ -330,7 +330,6 @@ data ChatMsgEvent (e :: MsgEncoding) where
XGrpLinkAcpt :: GroupAcceptance -> GroupMemberRole -> MemberId -> ChatMsgEvent 'Json
XGrpRelayInv :: ConnLinkContact -> ChatMsgEvent 'Json
XGrpRelayAcpt :: ConnLinkContact -> ChatMsgEvent 'Json -- TODO [chat relays] TBC short/long/any
-- XGrpRelayReady :: ChatMsgEvent 'Json
XGrpMemNew :: MemberInfo -> Maybe MsgScope -> ChatMsgEvent 'Json
XGrpMemIntro :: MemberInfo -> Maybe MemberRestrictions -> ChatMsgEvent 'Json
XGrpMemInv :: MemberId -> IntroInvitation -> ChatMsgEvent 'Json
@@ -821,7 +820,6 @@ data CMEventTag (e :: MsgEncoding) where
XGrpLinkAcpt_ :: CMEventTag 'Json
XGrpRelayInv_ :: CMEventTag 'Json
XGrpRelayAcpt_ :: CMEventTag 'Json
-- XGrpRelayReady_ :: CMEventTag 'Json
XGrpMemNew_ :: CMEventTag 'Json
XGrpMemIntro_ :: CMEventTag 'Json
XGrpMemInv_ :: CMEventTag 'Json
@@ -877,7 +875,6 @@ instance MsgEncodingI e => StrEncoding (CMEventTag e) where
XGrpLinkAcpt_ -> "x.grp.link.acpt"
XGrpRelayInv_ -> "x.grp.relay.inv"
XGrpRelayAcpt_ -> "x.grp.relay.acpt"
-- XGrpRelayReady_ -> "x.grp.relay.ready"
XGrpMemNew_ -> "x.grp.mem.new"
XGrpMemIntro_ -> "x.grp.mem.intro"
XGrpMemInv_ -> "x.grp.mem.inv"
@@ -934,7 +931,6 @@ instance StrEncoding ACMEventTag where
"x.grp.link.acpt" -> XGrpLinkAcpt_
"x.grp.relay.inv" -> XGrpRelayInv_
"x.grp.relay.acpt" -> XGrpRelayAcpt_
-- "x.grp.relay.ready" -> XGrpRelayReady_
"x.grp.mem.new" -> XGrpMemNew_
"x.grp.mem.intro" -> XGrpMemIntro_
"x.grp.mem.inv" -> XGrpMemInv_
@@ -987,7 +983,6 @@ toCMEventTag msg = case msg of
XGrpLinkAcpt {} -> XGrpLinkAcpt_
XGrpRelayInv _ -> XGrpRelayInv_
XGrpRelayAcpt _ -> XGrpRelayAcpt_
-- XGrpRelayReady -> XGrpRelayReady_
XGrpMemNew {} -> XGrpMemNew_
XGrpMemIntro _ _ -> XGrpMemIntro_
XGrpMemInv _ _ -> XGrpMemInv_
@@ -1107,7 +1102,6 @@ appJsonToCM AppMessageJson {v, msgId, event, params} = do
XGrpLinkAcpt_ -> XGrpLinkAcpt <$> p "acceptance" <*> p "role" <*> p "memberId"
XGrpRelayInv_ -> XGrpRelayInv <$> p "groupLink"
XGrpRelayAcpt_ -> XGrpRelayAcpt <$> p "relayLink"
-- XGrpRelayReady_ -> pure XGrpRelayReady
XGrpMemNew_ -> XGrpMemNew <$> p "memberInfo" <*> opt "scope"
XGrpMemIntro_ -> XGrpMemIntro <$> p "memberInfo" <*> opt "memberRestrictions"
XGrpMemInv_ -> XGrpMemInv <$> p "memberId" <*> p "memberIntro"
@@ -1169,7 +1163,6 @@ chatToAppMessage chatMsg@ChatMessage {chatVRange, msgId, chatMsgEvent} = case en
XGrpLinkAcpt acceptance role memberId -> o ["acceptance" .= acceptance, "role" .= role, "memberId" .= memberId]
XGrpRelayInv groupLink -> o ["groupLink" .= groupLink]
XGrpRelayAcpt relayLink -> o ["relayLink" .= relayLink]
-- XGrpRelayReady -> JM.empty
XGrpMemNew memInfo scope -> o $ ("scope" .=? scope) ["memberInfo" .= memInfo]
XGrpMemIntro memInfo memRestrictions -> o $ ("memberRestrictions" .=? memRestrictions) ["memberInfo" .= memInfo]
XGrpMemInv memId memIntro -> o ["memberId" .= memId, "memberIntro" .= memIntro]

View File

@@ -17,7 +17,7 @@ import Database.SQLite.Simple.QQ (sql)
-- - TBC also inverse link from group_relays to group_members? (group_relays.group_member_id)
-- - groups.relay_own_status - indicates for a relay client that it is chat relay for the group (GroupRelayStatus)
-- - connections.group_member_id_messaging - secondary connection for a group member in relayed group
-- TODO link between group_relays and chat_relays
-- TODO [chat relays] link between group_relays and chat_relays
m20251018_chat_relays :: Query
m20251018_chat_relays =
[sql|
@@ -42,10 +42,12 @@ ALTER TABLE users ADD COLUMN is_user_chat_relay INTEGER NOT NULL DEFAULT 0;
CREATE TABLE group_relays(
group_relay_id INTEGER PRIMARY KEY,
group_id INTEGER NOT NULL REFERENCES groups ON DELETE CASCADE,
group_member_id INTEGER NOT NULL REFERENCES group_members ON DELETE CASCADE,
relay_status TEXT NOT NULL,
relay_link BLOB
);
CREATE INDEX idx_group_relays_group_id ON group_relays(group_id);
CREATE INDEX idx_group_relays_group_member_id ON group_relays(group_member_id);
ALTER TABLE group_members ADD COLUMN is_chat_relay INTEGER NOT NULL DEFAULT 0;
@@ -67,6 +69,7 @@ DROP TABLE chat_relays;
ALTER TABLE users DROP COLUMN is_user_chat_relay;
DROP INDEX idx_group_relays_group_id;
DROP INDEX idx_group_relays_group_member_id;
DROP TABLE group_relays;
ALTER TABLE group_members DROP COLUMN is_chat_relay;