Refactor invitation handling in router.go
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-02-20 20:25:07 +01:00
parent db4c3cbbc8
commit defafcf996
5 changed files with 61 additions and 11 deletions

12
doc/sq_srvinv01.puml Normal file
View File

@ -0,0 +1,12 @@
@startuml Server Invitation Step 01
User -> Bastet : fill invitation
User -> Bastet : select servers
Bastet -> NativeLib : get server cards for selected uids
NativeLib -> Bastet : server cards
Bastet -> NativeLib : invitationCreateMessage
NativeLib -> Bastet : invitationMessage
Bastet -> Server : send invitation
Server -> Redis : Store invitation
Server -> Bastet : invitation URL
Bastet -> User : invitation URL
@enduml

11
doc/sq_srvinv02.puml Normal file
View File

@ -0,0 +1,11 @@
@startuml Server Invitation Step 02
User -> Bastet : paste URL
Bastet -> NativeLib : build invitationGetMessage
NativeLib -> Bastet : invitationGetMessage
Bastet -> Server : send invitationGetMessage
Redis -> Server : retrieve invitation
Server -> Bastet : invitation message
Bastet -> NativeLib : please invitation message
NativeLib -> Bastet : invitation message
Bastet -> User : invitation data
@enduml

12
doc/sq_srvinv03.puml Normal file
View File

@ -0,0 +1,12 @@
@startuml Server Invitation Step 03
User -> Bastet : select servers
User -> Bastet : accept invitation
Bastet -> NativeLib : accept invitation
Bastet -> NativeLib : build accept message
NativeLib -> Bastet : invitationGetMessage
Bastet -> Server : send accept message
Server -> Redis : store accept message
Server -> Bastet : accept message ok
Bastet -> User : msg sent
@enduml

10
doc/sq_srvinv04.puml Normal file
View File

@ -0,0 +1,10 @@
@startuml Server Invitation Step 03
Bastet -> NativeLib : periodic message check
Bastet -> NativeLib : build accept message
NativeLib -> Bastet : invitationGetMessage
Bastet -> Server : send accept message
Server -> Redis : store accept message
Server -> Bastet : accept message ok
Bastet -> User : msg sent
@enduml

View File

@ -141,17 +141,22 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe
from_server.Invitation.Payload = invitation // protobuf invitation from_server.Invitation.Payload = invitation // protobuf invitation
} }
/* should not happen case 3: // answer invitation
case 3: // answer invitation // just propagate the source publickey
expiry := r.AnswerInvitation(msg.Invitation.Id, int(msg.Invitation.Timeout), msg.Invitation.Payload, r.InvitationTimeout) from_server.Invitation.From = msg.Invitation.From
from_server.Invitation.Expiry = expiry.UTC().Unix()
case 4: // get answer //! store answer !!
answer, err := r.GetInvitationAnswer(msg.Invitation.Id) from_server.Invitation.Payload = msg.Invitation.Payload
if err != nil { /*
from_server.Invitation.Payload = []byte("invitation expired") expiry := r.AnswerInvitation(msg.Invitation.Id, int(msg.Invitation.Timeout), msg.Invitation.Payload, r.InvitationTimeout)
} else { from_server.Invitation.Expiry = expiry.UTC().Unix()
from_server.Invitation.Payload = answer case 4: // get answer
} answer, err := r.GetInvitationAnswer(msg.Invitation.Id)
if err != nil {
from_server.Invitation.Payload = []byte("invitation expired")
} else {
from_server.Invitation.Payload = answer
}
*/ */
} }
} }