diff options
author | Andrew Cady <d@cryptonomic.net> | 2022-12-01 09:24:36 -0500 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2022-12-01 09:24:36 -0500 |
commit | 4c11cc6cf603e99dfb5d671fc9804eaaee40289c (patch) | |
tree | 9f96280f5bb848379335b65e22ff74dea4040444 | |
parent | a6b757dc0444da71509fc10f3b01d4510f38be43 (diff) |
sketches of types, thoughts on vmail
-rw-r--r-- | types.hs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/types.hs b/types.hs new file mode 100644 index 0000000..bf2b4c4 --- /dev/null +++ b/types.hs | |||
@@ -0,0 +1,48 @@ | |||
1 | |||
2 | -- Invite a user by email address. | ||
3 | -- Records the username of the inviting user and the time of the | ||
4 | -- request. | ||
5 | data CreateInvitation = CreateInvitation Username Email UTCTime | ||
6 | createInvitation (CreateInvitation u e t) = do | ||
7 | x... | ||
8 | type Username = Text | ||
9 | data User = User UserID Username | ||
10 | |||
11 | data Provenance = ProvenanceSheet Sheet | ProvenanceUser User | ||
12 | data Invitation' id = Invitation' | ||
13 | { invitationID :: id | ||
14 | , invitationCreationTime :: UTCTime | ||
15 | , invitationEmailAddress :: EmailAddress -- invited user | ||
16 | , invitationProvenance :: Provenance -- inviting user | ||
17 | } | ||
18 | type CreateInvitation = Invitation' () | ||
19 | type Invitation = Invitation' UUID | ||
20 | createInvitation :: CreateInvitation -> m Invitation | ||
21 | createInvitation (CreateInvitation () t e (ProvenanceSheet s) = do | ||
22 | createInvitation (CreateInvitation () t e (ProvenanceUser u) = do | ||
23 | -- validate inviting user/sheet | ||
24 | -- record invitation code and shared secret in database | ||
25 | -- send email containing shared secret | ||
26 | |||
27 | -- preinvitations can be used to create invitations, | ||
28 | -- when email addresses are added | ||
29 | data PreInvitation' id = PreInvitation' | ||
30 | { preInvitationID :: id | ||
31 | , preInvitationSheetID :: Sheet | ||
32 | } | ||
33 | type CreatePreInvitation = PreInvitation' () | ||
34 | type PreInvitation = PreInvitation' PreInvitationCode | ||
35 | createPreInvitation :: CreatePreInvitation -> PreInvitation | ||
36 | |||
37 | -- A sheet containing preinvitations. | ||
38 | -- The preinvitations link up to their creating sheet. | ||
39 | data Sheet' id = Sheet' | ||
40 | { sheetID :: id | ||
41 | , sheetCreator :: User | ||
42 | , sheetCreationTime :: UTCTime | ||
43 | } | ||
44 | type CreateSheet = Sheet' () | ||
45 | type Sheet = Sheet' SheetID | ||
46 | type SheetID = UUID | ||
47 | createSheet :: CreateSheet -> m Sheet | ||
48 | |||