summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2022-12-01 09:24:36 -0500
committerAndrew Cady <d@cryptonomic.net>2022-12-01 09:24:36 -0500
commit4c11cc6cf603e99dfb5d671fc9804eaaee40289c (patch)
tree9f96280f5bb848379335b65e22ff74dea4040444
parenta6b757dc0444da71509fc10f3b01d4510f38be43 (diff)
sketches of types, thoughts on vmail
-rw-r--r--types.hs48
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.
5data CreateInvitation = CreateInvitation Username Email UTCTime
6createInvitation (CreateInvitation u e t) = do
7 x...
8type Username = Text
9data User = User UserID Username
10
11data Provenance = ProvenanceSheet Sheet | ProvenanceUser User
12data Invitation' id = Invitation'
13 { invitationID :: id
14 , invitationCreationTime :: UTCTime
15 , invitationEmailAddress :: EmailAddress -- invited user
16 , invitationProvenance :: Provenance -- inviting user
17 }
18type CreateInvitation = Invitation' ()
19type Invitation = Invitation' UUID
20createInvitation :: CreateInvitation -> m Invitation
21createInvitation (CreateInvitation () t e (ProvenanceSheet s) = do
22createInvitation (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
29data PreInvitation' id = PreInvitation'
30 { preInvitationID :: id
31 , preInvitationSheetID :: Sheet
32 }
33type CreatePreInvitation = PreInvitation' ()
34type PreInvitation = PreInvitation' PreInvitationCode
35createPreInvitation :: CreatePreInvitation -> PreInvitation
36
37-- A sheet containing preinvitations.
38-- The preinvitations link up to their creating sheet.
39data Sheet' id = Sheet'
40 { sheetID :: id
41 , sheetCreator :: User
42 , sheetCreationTime :: UTCTime
43 }
44type CreateSheet = Sheet' ()
45type Sheet = Sheet' SheetID
46type SheetID = UUID
47createSheet :: CreateSheet -> m Sheet
48