Received messages codecs are okay-ish (some properties are missing in UserPublic module).
This commit is contained in:
parent
d12278be30
commit
f66aba1c41
@ -50,7 +50,6 @@ import App.IPC as IPC
|
||||
-- Deletion can be triggered by either an admin or the user.
|
||||
|
||||
Possible answers:
|
||||
- 11 type MatchingUsers = { users :: Array(UserPublic.UserPublic) }
|
||||
-}
|
||||
|
||||
-- Basic message types.
|
||||
@ -67,6 +66,7 @@ type PermissionSet = { user :: Int, service :: String, resource :: String
|
||||
type PasswordRecoverySent = { user :: UserPublic.UserPublic }
|
||||
type PasswordRecovered = { user :: UserPublic.UserPublic }
|
||||
type Contacts = { user :: Int, email :: Maybe Email.Email, phone :: Maybe Phone.Phone }
|
||||
type MatchingUsers = { users :: Array UserPublic.UserPublic }
|
||||
|
||||
type Password = String
|
||||
type GetToken = { login :: String, password :: String }
|
||||
@ -91,8 +91,8 @@ codecGotUserValidated ∷ CA.JsonCodec UserValidated
|
||||
codecGotUserValidated = CA.object "UserValidated" (CAR.record { user: UserPublic.codec })
|
||||
codecGotPasswordRecovered ∷ CA.JsonCodec PasswordRecovered
|
||||
codecGotPasswordRecovered = CA.object "PasswordRecovered" (CAR.record { user: UserPublic.codec })
|
||||
-- codecGotUsersList ∷ CA.JsonCodec UsersList
|
||||
-- codecGotUsersList = CA.object "UsersList" (CAR.record { users: TODO })
|
||||
codecGotUsersList ∷ CA.JsonCodec UsersList
|
||||
codecGotUsersList = CA.object "UsersList" (CAR.record { users: CA.array UserPublic.codec })
|
||||
codecGotPermissionCheck :: CA.JsonCodec PermissionCheck
|
||||
codecGotPermissionCheck = CA.object "PermissionCheck" (CAR.record { user: CA.int
|
||||
, service: CA.string
|
||||
@ -107,6 +107,8 @@ codecGotContacts ∷ CA.JsonCodec Contacts
|
||||
codecGotContacts = CA.object "Contacts" (CAR.record { user: CA.int
|
||||
, email: CAR.optional Email.codec
|
||||
, phone: CAR.optional Phone.codec })
|
||||
codecGotMatchingUsers ∷ CA.JsonCodec MatchingUsers
|
||||
codecGotMatchingUsers = CA.object "MatchingUsers" (CAR.record { users: CA.array UserPublic.codec })
|
||||
|
||||
-- All possible requests.
|
||||
data RequestMessage
|
||||
@ -131,19 +133,19 @@ data RequestMessage
|
||||
|
||||
-- All possible answers from the authentication daemon (authd).
|
||||
data AnswerMessage
|
||||
= GotError Error -- 0
|
||||
| GotToken Token -- 1
|
||||
| GotUser User -- 2
|
||||
| GotUserAdded UserAdded -- 3
|
||||
| GotUserEdited UserEdited -- 4
|
||||
| GotUserValidated UserValidated -- 5
|
||||
-- | GotUsersList UsersList -- 6
|
||||
| GotPermissionCheck PermissionCheck -- 7
|
||||
| GotPermissionSet PermissionSet -- 8
|
||||
| GotPasswordRecoverySent PasswordRecoverySent -- 9
|
||||
| GotPasswordRecovered PasswordRecovered -- 10
|
||||
-- | GotMatchingUsers MatchingUsers -- 11
|
||||
| GotContacts Contacts -- 12
|
||||
= GotError Error -- 0
|
||||
| GotToken Token -- 1
|
||||
| GotUser User -- 2
|
||||
| GotUserAdded UserAdded -- 3
|
||||
| GotUserEdited UserEdited -- 4
|
||||
| GotUserValidated UserValidated -- 5
|
||||
| GotUsersList UsersList -- 6
|
||||
| GotPermissionCheck PermissionCheck -- 7
|
||||
| GotPermissionSet PermissionSet -- 8
|
||||
| GotPasswordRecoverySent PasswordRecoverySent -- 9
|
||||
| GotPasswordRecovered PasswordRecovered -- 10
|
||||
| GotMatchingUsers MatchingUsers -- 11
|
||||
| GotContacts Contacts -- 12
|
||||
|
||||
encode ∷ RequestMessage -> Tuple UInt String
|
||||
encode m = case m of
|
||||
@ -180,12 +182,12 @@ decode number string
|
||||
3 -> error_management codecGotUserAdded GotUserAdded
|
||||
4 -> error_management codecGotUserEdited GotUserEdited
|
||||
5 -> error_management codecGotUserValidated GotUserValidated
|
||||
-- 6 type UsersList = { users :: Array(UserPublic.UserPublic) }
|
||||
6 -> error_management codecGotUsersList GotUsersList
|
||||
7 -> error_management codecGotPermissionCheck GotPermissionCheck
|
||||
8 -> error_management codecGotPermissionSet GotPermissionSet
|
||||
9 -> error_management codecGotPasswordRecoverySent GotPasswordRecoverySent
|
||||
10 -> error_management codecGotPasswordRecovered GotPasswordRecovered
|
||||
-- 11 type MatchingUsers = { users :: Array(UserPublic.UserPublic) }
|
||||
11 -> error_management codecGotMatchingUsers GotMatchingUsers
|
||||
12 -> error_management codecGotContacts GotContacts
|
||||
_ -> Left UnknownNumber
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user