2016-11-30 05:08:35 +00:00
|
|
|
#lang racket/base
|
|
|
|
|
|
|
|
(provide (all-defined-out)) ;; TODO
|
|
|
|
|
2016-12-06 02:04:41 +00:00
|
|
|
;; A Markup is a String containing very carefully-chosen extensions
|
|
|
|
;; that allow a little bit of plain-text formatting without opening
|
|
|
|
;; the system up to Cross-Site Scripting (XSS) vulnerabilities.
|
|
|
|
|
2016-11-30 05:08:35 +00:00
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Server State
|
|
|
|
|
|
|
|
;; (server-baseurl URLString)
|
|
|
|
(struct server-baseurl (string) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Session and Account Management
|
|
|
|
|
|
|
|
;; (session EmailString String)
|
|
|
|
;; Represents a live session. Retracted when the session ends.
|
|
|
|
(struct session (email token) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;; (login-link EmailString String)
|
|
|
|
;; Represents the availability of a non-expired login link. Retracted when the link expires.
|
|
|
|
(struct login-link (email token) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;; (end-session String)
|
|
|
|
;; Instructs any matching session to terminate.
|
|
|
|
(struct end-session (token) #:prefab) ;; MESSAGE
|
|
|
|
|
|
|
|
;; (account EmailString)
|
|
|
|
;; Represents an extant account.
|
|
|
|
(struct account (email) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; API requests and assertions
|
|
|
|
|
|
|
|
;; (api Session Any)
|
|
|
|
;; Represents some value asserted or transmitted on behalf of the
|
|
|
|
;; given user session. Values of this type cannot be trusted, since
|
|
|
|
;; they originate with the user's client, which may be the browser or
|
|
|
|
;; may be some other client.
|
|
|
|
(struct api (session value) #:prefab) ;; ASSERTION AND MESSAGE
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Create, Update and Delete
|
|
|
|
|
|
|
|
;; (create-resource Any)
|
|
|
|
;; Request creation of the given resource as described.
|
|
|
|
(struct create-resource (description) #:prefab) ;; MESSAGE
|
|
|
|
|
|
|
|
;; (update-resource Any)
|
|
|
|
;; Request update of the given resource as described.
|
|
|
|
(struct update-resource (description) #:prefab) ;; MESSAGE
|
|
|
|
|
|
|
|
;; (delete-resource Any)
|
|
|
|
;; Request deletion of the given resource as described.
|
|
|
|
(struct delete-resource (description) #:prefab) ;; MESSAGE
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Capability Management
|
|
|
|
|
|
|
|
;; A Principal is an EmailString
|
|
|
|
|
|
|
|
;; TODO: Action: report a cap request as spam or some other kind of nuisance
|
|
|
|
|
|
|
|
;; (grant Principal Principal Principal Any Boolean)
|
|
|
|
;; Links in a grant chain.
|
|
|
|
(struct grant (issuer grantor grantee permission delegable?) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;; (permitted Principal Principal Any Boolean)
|
|
|
|
;; Net results of processing grant chains. Query these.
|
|
|
|
(struct permitted (issuer email permission delegable?) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;; (permission-request Principal Principal Any)
|
|
|
|
;; Represents an outstanding request for a permission.
|
|
|
|
;; Satisfied by either - appearance of a matching Grant
|
|
|
|
;; - receipt of a matching Revoke
|
|
|
|
;; - receipt of a CancelRequest
|
|
|
|
(struct permission-request (issuer grantee permission) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Contact List Management
|
|
|
|
|
|
|
|
;; M Capability to invite X to a conversation
|
|
|
|
;; W Capability to see onlineness of X
|
|
|
|
;; W Capability to silently block X from contacting one in any way
|
|
|
|
;; W Capability to visibly block X from contacting one in any way
|
|
|
|
;; W Capability to mute an individual outside the context of any particular conversation for a certain length of time
|
|
|
|
|
2016-12-06 02:04:41 +00:00
|
|
|
;; (contact-list-entry Principal Principal)
|
|
|
|
;; Asserts that `member` is a member of the contact list owned by `owner`.
|
|
|
|
(struct contact-list-entry (owner member) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;; (p:follow Principal)
|
|
|
|
;; When (permitted X Y (p:follow X) _), X says that Y may follow X.
|
2016-11-30 05:08:35 +00:00
|
|
|
(struct p:follow (email) #:prefab)
|
2016-12-06 02:04:41 +00:00
|
|
|
|
2016-11-30 05:08:35 +00:00
|
|
|
;; (struct p:invite (email) #:prefab)
|
|
|
|
;; (struct p:see-presence (email) #:prefab)
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; Conversation Management
|
|
|
|
|
|
|
|
;; M Capability to destroy a conversation
|
|
|
|
;; M Capability to invite someone inviteable to a conversation
|
|
|
|
;; M Capability to cancel an open invitation
|
|
|
|
;; M Capability to boot someone from a conversation
|
|
|
|
;; M Capability to leave a conversation
|
|
|
|
;; M Capability to reject an invitation to a conversation
|
|
|
|
;; M Capability to accept an invitation to a conversation
|
|
|
|
;; M Capability to see the list of participants in a conversation
|
|
|
|
;; M Capability to publish posts to a conversation
|
|
|
|
;; S Capability to remove or edit one's own posts
|
|
|
|
;; S Capability to remove or edit other people's posts
|
|
|
|
;; C Capability to clear conversation history
|
|
|
|
;; C Capability to react to a post on a conversation
|
|
|
|
;; W Capability to delegate capabilities to others
|
|
|
|
;; W Capability to mute a conversation for a certain length of time
|
|
|
|
;; W Capability to mute an individual within the context of a particular conversation for a certain length of time
|
|
|
|
;; W Capability to have a conversation joinable by ID, without an invitation
|
|
|
|
;; W Capability to have a conversation be publicly viewable
|
|
|
|
;; W Capability to draft posts before publication
|
|
|
|
;; W Capability to approve draft posts
|
|
|
|
|
|
|
|
;; TODO: For now, all members will have all conversation control
|
|
|
|
;; abilities. Later, these can be split out into separate permissions.
|
|
|
|
|
|
|
|
;; Attribute: conversation title
|
|
|
|
;; Attribute: conversation creator
|
|
|
|
;; Attribute: conversation blurb
|
|
|
|
;; Attribute: conversation members
|
|
|
|
|
|
|
|
;; Simple posting is a combination of draft+approve.
|
|
|
|
;; Flagging a post for moderator attention is a kind of reaction.
|
|
|
|
|
2016-12-06 02:04:41 +00:00
|
|
|
;; (conversation String String Principal Markup Boolean
|
2016-11-30 05:08:35 +00:00
|
|
|
(struct conversation (id title creator blurb) #:prefab) ;; ASSERTION
|
|
|
|
|
2016-12-06 21:06:32 +00:00
|
|
|
;; (invitation String Principal Principal)
|
|
|
|
(struct invitation (conversation-id inviter invitee) #:prefab) ;; ASSERTION
|
2016-11-30 05:08:35 +00:00
|
|
|
|
|
|
|
;; (in-conversation String Principal)
|
|
|
|
;; Records conversation membership.
|
|
|
|
(struct in-conversation (conversation-id member) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
(struct post (id ;; String
|
|
|
|
timestamp ;; Seconds
|
|
|
|
conversation-id ;; String
|
2016-12-07 06:19:32 +00:00
|
|
|
author ;; Principal
|
2016-12-13 21:36:35 +00:00
|
|
|
items ;; Listof DataURLString
|
2016-11-30 05:08:35 +00:00
|
|
|
) #:prefab) ;; ASSERTION
|
|
|
|
|
|
|
|
;;---------------------------------------------------------------------------
|
|
|
|
;; User Interaction
|
|
|
|
|
|
|
|
;; (ui-template String String)
|
|
|
|
;; A fragment of HTML for use in the web client.
|
|
|
|
(struct ui-template (name data) #:prefab) ;; ASSERTION
|
|
|
|
|
2016-12-06 02:04:41 +00:00
|
|
|
;; (question String Seconds String Principal String Markup QuestionType)
|
|
|
|
(struct question (id timestamp class target title blurb type) #:prefab) ;; ASSERTION
|
2016-11-30 05:08:35 +00:00
|
|
|
|
|
|
|
;; (answer String Any)
|
|
|
|
(struct answer (id value) #:prefab) ;; MESSAGE
|
|
|
|
|
|
|
|
;; A QuestionType is one of
|
2016-12-06 02:04:41 +00:00
|
|
|
;; - (yes/no-question Markup Markup)
|
|
|
|
;; - (option-question (Listof (List Any Markup)))
|
2016-11-30 05:08:35 +00:00
|
|
|
;; - (text-question Boolean)
|
|
|
|
(struct yes/no-question (false-value true-value) #:prefab)
|
|
|
|
(struct option-question (options) #:prefab)
|
|
|
|
(struct text-question (multiline?) #:prefab)
|
2016-12-06 02:04:41 +00:00
|
|
|
(struct acknowledge-question () #:prefab)
|