| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ssb.Types.Message
- type Signature = String
- data Message a = Message {}
- messageLink :: Hashed (Message a) -> MessageLink
- data AnyContent = AnyContent {}
- contentType :: Message AnyContent -> Text
- parseMessage :: FromJSON a => ByteString -> Maybe (Hashed (Message a))
- narrowParse :: FromJSON a => Message AnyContent -> Parser (Message a)
- data PrivateContent = PrivateContent Text
- data Post = Post {}
- data UserLink = UserLink {}
- data About = About {}
- data AboutImage = AboutImage {}
- data Contact = Contact {}
- data Vote = Vote {}
- data Pub = Pub {}
- parseMessageType :: Text -> (Value -> Parser a) -> Value -> Parser a
Documentation
Constructors
| Message | |
messageLink :: Hashed (Message a) -> MessageLink Source #
data AnyContent Source #
Parsing a Message AnyContent allows parsing the message envelope, regardless of the type of content in the message.
Constructors
| AnyContent | |
Fields | |
Instances
contentType :: Message AnyContent -> Text Source #
Get the declared type of content in a Message AnyContent.
parseMessage :: FromJSON a => ByteString -> Maybe (Hashed (Message a)) Source #
Parses a JSON formatted message, and accompanies it with the hash that was originally used for the message.
narrowParse :: FromJSON a => Message AnyContent -> Parser (Message a) Source #
For best efficiency when the type of a message is not known,
first parse to a Message AnyContent, and then use this function
with parseMaybe or parseEither to try to further parse that
to different message types.
For example:
Just somemsg = decode b :: Maybe Message AnyContent
case parseMaybe narrowParse somemsg :: Maybe (Message Post) of
Just postmsg -> ...
Nothing -> case parseMaybe narrowParse somemsg :: Maybe (Message PrivateContent) of
Just privmsg -> ...
Nothing -> ...data PrivateContent Source #
A message with encrypted content.
Constructors
| PrivateContent Text |
Instances
A post is a text-based message, for a public or private audience. It can be a reply to other posts.
Constructors
| Post | |
A link to a user, sometimes including a name.
About-messages set attributes about someone or something. They can be used to set a name or picture for users, files, or messages. However, they're most commonly published about users.
Constructors
| About | |
data AboutImage Source #
Constructors
| AboutImage | |
Fields | |
Instances
| Eq AboutImage Source # | |
| Show AboutImage Source # | |
| Generic AboutImage Source # | |
| FromJSON AboutImage Source # | AboutImage can be encoded as either a JSON object or as a string, which is the BlobLink. |
| type Rep AboutImage Source # | |
Contact-messages determine who you are following or blocking.
Vote-messages signal approval about someone or something. Votes can be on users, messages, or blobs.