# Group Messaging (Different DHT)
###### tags: `Kizuna-architecture`
#### comments
- how to add/remove groups in different DHT
- TODO: sync/async invites flow
- TODO: workflow for when cloneDNA is not successful
- Since it's a separate DNA, is it safe to store messages in DHT
### GroupMessageEntry
``` rust
// private entry commited in source chain
pub struct Invite {
group_uui: String,
initial_members: Vec<AgentPubKey>,
timestamp: Timestamp
}
pub struct Groups {
group_uuids: Vec<String>,
blocked: Vec<String>
}
pub struct MessageEntry {
author: AgentPubKey,
receiver: Vec<AgentPubKey>,
group_uuid: String,
payload: String,
time_sent: Timestamp,
time_received: Option<Timestamp>
}
```
```mermaid
sequenceDiagram
participant AUI as Alice_UI
participant ALD as Alice_Lobby_DNA
participant AC as Alice_Conductor
participant BUI as Bobby_UI
participant BLD as Bobby_Lobby_DNA
participant CUI as Charlie_UI
participant CLD as Charlie_Lobby_DNA
participant LDHT as Lobby_DHT
participant GDHT as Group_DHT
ALD-->>AUI: fetch Groups entry
BLD-->>BUI: fetch Groups entry
CLD-->>CUI: fetch Groups entry
AUI-->>AUI: choose participants in GC
AUI-->>ALD: send usernames/agent pubkeys
par alit to bob
ALD-->>BLD: send invite
and alice to clarice
ALD-->>CLD: send invite
end
AC-->>AC: create the new group DNA from tempalte
alt success
AC-->>AUI: cloneDNA successful
else fail
note left of AC: TODO
end
alt attempt synchronous messaging
par sending to Bobby
ALD-->>BLD: call_remote! receive_group_message
BLD-->>BLD: check the group_id
alt group is blocked
BLD-->>BLD: do nothing
else group is not blocked
BLD-->>BLD: check the receivers
alt someone is blocked in group
BLD-->>BUI: emit_signal the message along with warning that someone in group is blocked
else no one is blocked
BLD-->>BUI: emit_signal the message
end
end
BUI-->>BUI: check whether it's the first message of the group by filtering against Groups entry
alt first time
BUI-->>BUI: show the accept, delete, block banner
end
and sending to Charlie
note right of BUI: Same with Alice </br> to Bobby
end
ALD-->>AUI: return success
else switch to asynchronous messaging for offline contacts
ALD-->>LDHT: commit message in DHT
LDHT-->>ALD: return message address
ALD-->>LDHT: link message to Bobby's GroupChats entry
LDHT-->>ALD: return success
ALD-->>AUI: return success
end
```