@@ -3,10 +3,34 @@ package main
33import "github.com/mriceman/go-uml/sequence"
44
55func main () {
6- userStartsChatting ()
7- userBIsNotPartOfChat ()
8- UserBIsPartOfChat ()
6+ userJoinsChat ()
7+ }
8+
9+ func userJoinsChat () {
10+ d := sequence .NewDiagram ("new_chat" )
11+ userA := "userA (name could be quite longer)"
12+ userB := "userB"
13+ b := "backend"
14+
15+ d .SetTitle ("User starts a chat with someone (doesn't matter if new or not)" )
16+
17+ d .AddParticipants (userA , userB , b )
18+
19+ _ = d .AddDirectionalEdge (userA , b , `POST /inbox {"recipient": userID, "project": projectID, "projectType": challenge|solution}"` )
20+ _ = d .AddDirectionalEdge (b , userA , "Response Status Code: 202, Body: Inbox{id, secret, recipient, ...}" )
21+ _ = d .AddDirectionalEdge (userA , b , "WS connect" )
22+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "JOIN", "data": {"inboxId": str, "userId": "str", "inboxSecret": str}}"` )
23+ _ = d .AddDirectionalEdge (b , b , "STORE_CONNECTION_ID(userA)" )
24+ _ = d .AddDirectionalEdge (b , b , "sets unread inbox userA = 0" )
25+ _ = d .AddDirectionalEdge (b , userA , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
26+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "SEND_MESSAGE", "data": {"inboxId": str, "userId": "str", "inboxSecret": str, "content": "hi"}}"` )
27+ _ = d .AddDirectionalEdge (b , b , "check connectionID userB" )
28+ _ = d .AddUndirectionalEdge (b , b , "if connected: " )
29+ _ = d .AddDirectionalEdge (b , userB , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
30+ _ = d .AddUndirectionalEdge (b , b , "else: " )
31+ _ = d .AddUndirectionalEdge (b , b , "increment unread inbox userB" )
932
33+ d .Render ()
1034}
1135
1236func UserBIsPartOfChat () {
@@ -71,6 +95,7 @@ func userStartsChatting() {
7195 d .AddParticipants (backend )
7296 d .AddParticipants (db )
7397
98+ d .AddDirectionalEdge (client , backend , "GET /inbox/<TO_ID>" )
7499 d .AddDirectionalEdge (client , backend , "PUT /chat/user/<TO_ID>" )
75100 d .AddDirectionalEdge (backend , db , "checks or create inbox for user" )
76101 d .AddDirectionalEdge (backend , db , "set all unread messages to read if existing" )
0 commit comments