Define APIs for ThreePid component

This commit is contained in:
Piotr Kozimor 2021-06-07 11:17:00 +02:00
parent caa5c89ecb
commit 35622c8b94
2 changed files with 46 additions and 0 deletions

38
threepid/api.go Normal file
View file

@ -0,0 +1,38 @@
package threepid
import "context"
type API interface {
CreateSession(context.Context, *CreateSessionRequest, *Session) error
ValidateSession(context.Context, *ValidateSessionRequest, struct{}) error
GetThreePidForSession(context.Context, *SessionOwnership, *GetThreePidForSessionResponse) error
DeleteSession(context.Context, *SessionOwnership, struct{}) error
IsSessionValidated(context.Context, *SessionOwnership, *IsSessionValidatedResponse) error
}
type CreateSessionRequest struct {
ClientSecret, NextLink, ThreePid string
}
type ValidateSessionRequest struct {
SessionOwnership
Token string
}
type GetThreePidForSessionResponse struct {
ThreePid string
}
type SessionOwnership struct {
Sid, ClientSecret string
}
type Session struct {
Sid, ClientSecret, ThreePid, Token, NextLink string
SendAttempt int
}
type IsSessionValidatedResponse struct {
Validated bool
ValidatedAt int
}

8
threepid/storage.go Normal file
View file

@ -0,0 +1,8 @@
package threepid
type storage interface {
InsertSession(*Session) error
GetSession(sid string) (*Session, error)
GetSessionByThreePidAndSecret(threePid, ClientSecret string) (*Session, error)
RemoveSession(sid string) error
}