| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ssb.Types.Message
- type Signature = String
- data Message a = Message {}
- messageLink :: Hashed (Message a) -> MessageLink
- data AnyContent = AnyContent {}
- parseMessage :: FromJSON a => ByteString -> Maybe (Hashed (Message a))
- narrowParse :: FromJSON a => Message AnyContent -> Parser (Message a)
- data PrivateContent = PrivateContent Text
- data Post = Post {}
- data Mention = Mention {
- mentionLink :: Link
- 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
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 generic reference to other feeds, entities, or blobs
Constructors
| Mention | |
Fields
| |
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.
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.