@@ -6,7 +6,34 @@ func main() {
6
6
userStartsChatting ()
7
7
userBIsNotPartOfChat ()
8
8
userBIsPartOfChat ()
9
+ userJoinsChat ()
10
+ }
11
+
12
+ func userJoinsChat () {
13
+ d := sequence .NewDiagram ("new_chat" )
14
+ userA := "userA (name could be quite longer)"
15
+ userB := "userB"
16
+ b := "backend"
17
+
18
+ d .SetTitle ("User starts a chat with someone (doesn't matter if new or not)" )
19
+
20
+ d .AddParticipants (userA , userB , b )
21
+
22
+ _ = d .AddDirectionalEdge (userA , b , `POST /inbox {"recipient": userID, "project": projectID, "projectType": challenge|solution}"` )
23
+ _ = d .AddDirectionalEdge (b , userA , "Response Status Code: 202, Body: Inbox{id, secret, recipient, ...}" )
24
+ _ = d .AddDirectionalEdge (userA , b , "WS connect" )
25
+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "JOIN", "data": {"inboxId": str, "userId": "str", "inboxSecret": str}}"` )
26
+ _ = d .AddDirectionalEdge (b , b , "STORE_CONNECTION_ID(userA)" )
27
+ _ = d .AddDirectionalEdge (b , b , "sets unread inbox userA = 0" )
28
+ _ = d .AddDirectionalEdge (b , userA , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
29
+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "SEND_MESSAGE", "data": {"inboxId": str, "userId": "str", "inboxSecret": str, "content": "hi"}}"` )
30
+ _ = d .AddDirectionalEdge (b , b , "check connectionID userB" )
31
+ _ = d .AddUndirectionalEdge (b , b , "if connected: " )
32
+ _ = d .AddDirectionalEdge (b , userB , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
33
+ _ = d .AddUndirectionalEdge (b , b , "else: " )
34
+ _ = d .AddUndirectionalEdge (b , b , "increment unread inbox userB" )
9
35
36
+ d .Render ()
10
37
}
11
38
12
39
func userBIsPartOfChat () {
@@ -71,6 +98,7 @@ func userStartsChatting() {
71
98
d .AddParticipants (backend )
72
99
d .AddParticipants (db )
73
100
101
+ d .AddDirectionalEdge (client , backend , "GET /inbox/<TO_ID>" )
74
102
d .AddDirectionalEdge (client , backend , "PUT /chat/user/<TO_ID>" )
75
103
d .AddDirectionalEdge (backend , db , "checks or create inbox for user" )
76
104
d .AddDirectionalEdge (backend , db , "set all unread messages to read if existing" )
0 commit comments