This commit is contained in:
spaced4ndy
2025-10-22 20:36:15 +04:00
parent 7a12fe304f
commit 1121b09009
3 changed files with 40 additions and 14 deletions
+11 -2
View File
@@ -215,7 +215,7 @@ par With each relay
R ->> O: 10. Accept request<br>(x.grp.relay.acpt<br>incl. relay link)
note over O, R: Priority connection<br>with relay is ready
O ->> OSMP: 11. Update short link<br>(add relay link)
O ->> R: 12. Connect via relay link
O ->> R: 12. Connect via relay link<br>(share same owner key)
note over O, R: Owner: Messages connection with relay is ready,<br>relay link is tested<br>Relay: Relay link is active
end
create participant M as Member
@@ -224,7 +224,11 @@ O -->> M: 13. Share group short link<br>(social, out-of-band)
note over O, M: New member connects
M ->> OSMP: 14. Retrieve short link data
M ->> R: 15. Connect via relay link(s)
par Priority connection
M ->> R: 15a. Connect via relay link
and Messages connection
M ->> R: 15b. Connect via relay link<br>(share same member key/<br>identifier to correlate)
end
note over O, M: Message forwarding
@@ -233,6 +237,11 @@ R ->> M: 17. Forward message
M ->> M: 18. Deduplicate message
```
Notes:
- Invitation sent in step 12 should contain same key as in group link, for relay to match connection to the same owner and "active" relay link (add to `XContact` message).
- Add new connection entity, special for groups with relay, referencing member record - parallel to first member connection.
## Protocol for removing chat relay from group, restoring connection to group
@@ -51,6 +51,9 @@ ALTER TABLE group_members ADD COLUMN group_relay_id INTEGER REFERENCES group_rel
CREATE INDEX idx_group_members_group_relay_id ON group_members(group_relay_id);
ALTER TABLE groups ADD COLUMN relay_own_status TEXT;
ALTER TABLE connections ADD COLUMN group_member_id_low_priority INTEGER REFERENCES group_members ON DELETE CASCADE;
CREATE INDEX idx_connections_group_member_id_low_priority ON connections(group_member_id_low_priority);
|]
down_m20251016_chat_relays :: Query
@@ -70,4 +73,7 @@ DROP INDEX idx_group_members_group_relay_id;
ALTER TABLE group_members DROP COLUMN group_relay_id;
ALTER TABLE groups DROP COLUMN relay_own_status;
DROP INDEX idx_connections_group_member_id_low_priority;
ALTER TABLE connections DROP COLUMN group_member_id_low_priority;
|]
+23 -12
View File
@@ -974,24 +974,35 @@ data GroupRelay = GroupRelay
}
deriving (Eq, Show)
-- Status tracked by owner per relay
-- -- Status tracked by owner per relay
-- data GroupRelayStatus
-- = GRSNew
-- | GRSInvited
-- | GRSAccepted
-- | GRSAdded
-- | GRSNotified
-- | GRSConfirmed
-- deriving (Eq, Show)
-- -- Own status tracked by relay in a group
-- data GroupRelayOwnStatus
-- = GROSInvited
-- | GROSLinkCreated
-- | GROSAccepted
-- | GROSNotified
-- | GROSConfirmed
-- TODO [chat relays] single type for statuses both on owner and relay side?
data GroupRelayStatus
= GRSNew
= GRSNew -- only for owner
| GRSInvited
| GRSVerified -- only for relay
| GRSLinkCreated -- only for relay
| GRSAccepted
| GRSAdded
| GRSNotified
| GRSAdded -- only for owner
| GRSConfirmed
deriving (Eq, Show)
-- Own status tracked by relay in a group
data GroupRelayOwnStatus
= GROSInvited
| GROSLinkCreated
| GROSAccepted
| GROSNotified
| GROSConfirmed
data GroupSupportChat = GroupSupportChat
{ chatTs :: UTCTime,
unread :: Int64,