scuttlebutt-types-0.3.0: generic types for Secure Scuttlebutt

Safe HaskellNone
LanguageHaskell2010

Ssb.Types.Message

Synopsis

Documentation

data Message a Source #

Instances

Functor Message Source # 

Methods

fmap :: (a -> b) -> Message a -> Message b #

(<$) :: a -> Message b -> Message a #

Eq a => Eq (Message a) Source # 

Methods

(==) :: Message a -> Message a -> Bool #

(/=) :: Message a -> Message a -> Bool #

Show a => Show (Message a) Source # 

Methods

showsPrec :: Int -> Message a -> ShowS #

show :: Message a -> String #

showList :: [Message a] -> ShowS #

Generic (Message a) Source # 

Associated Types

type Rep (Message a) :: * -> * #

Methods

from :: Message a -> Rep (Message a) x #

to :: Rep (Message a) x -> Message a #

FromJSON a => FromJSON (Message a) Source # 
type Rep (Message a) Source # 

data AnyContent Source #

Parsing a Message AnyContent allows parsing the message envelope, regardless of the type of content in the message.

Constructors

AnyContent 

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 Post Source #

A post is a text-based message, for a public or private audience. It can be a reply to other posts.

newtype Branch Source #

Link to the message in the thread that a Post replies to.

Generally there is only one link, but sometimes more than one.

Constructors

Branch 

Fields

newtype Mentions Source #

Constructors

Mentions 

Fields

Instances

Eq Mentions Source # 
Show Mentions Source # 
Monoid Mentions Source # 
FromJSON Mentions Source #

Sometimes it's an array of objects. Sometimes there is no array, but a single object. And sometimes the Mention contains an invalid Link; avoid failing on those.

data Mention Source #

A reference to other feeds, entities, or blobs that were mentioned in a Post.

Constructors

Mention 

Instances

Eq Mention Source # 

Methods

(==) :: Mention -> Mention -> Bool #

(/=) :: Mention -> Mention -> Bool #

Show Mention Source # 
Generic Mention Source # 

Associated Types

type Rep Mention :: * -> * #

Methods

from :: Mention -> Rep Mention x #

to :: Rep Mention x -> Mention #

FromJSON Mention Source # 
type Rep Mention Source # 
type Rep Mention = D1 (MetaData "Mention" "Ssb.Types.Message" "scuttlebutt-types-0.3.0-6xo5f986M2o6O3PfclG0SI" False) (C1 (MetaCons "Mention" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "mentionLink") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Link)) (S1 (MetaSel (Just Symbol "mentionName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text)))))

data About Source #

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 #

Instances

Eq AboutImage Source # 
Show AboutImage Source # 
Generic AboutImage Source # 

Associated Types

type Rep AboutImage :: * -> * #

FromJSON AboutImage Source #

AboutImage can be encoded as either a JSON object or as a string, which is the BlobLink.

type Rep AboutImage Source # 

data Contact Source #

Contact-messages determine who you are following or blocking.

Constructors

Contact 

Instances

data Vote Source #

Vote-messages signal approval about someone or something. Votes can be on users, messages, or blobs.

Constructors

Vote 

Instances

Eq Vote Source # 

Methods

(==) :: Vote -> Vote -> Bool #

(/=) :: Vote -> Vote -> Bool #

Show Vote Source # 

Methods

showsPrec :: Int -> Vote -> ShowS #

show :: Vote -> String #

showList :: [Vote] -> ShowS #

Generic Vote Source # 

Associated Types

type Rep Vote :: * -> * #

Methods

from :: Vote -> Rep Vote x #

to :: Rep Vote x -> Vote #

FromJSON Vote Source # 
type Rep Vote Source # 
type Rep Vote = D1 (MetaData "Vote" "Ssb.Types.Message" "scuttlebutt-types-0.3.0-6xo5f986M2o6O3PfclG0SI" False) (C1 (MetaCons "Vote" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "voteLink") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Link)) ((:*:) (S1 (MetaSel (Just Symbol "voteValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Just Symbol "voteExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))))))

data Pub Source #

Constructors

Pub 

Fields

Instances

Eq Pub Source # 

Methods

(==) :: Pub -> Pub -> Bool #

(/=) :: Pub -> Pub -> Bool #

Show Pub Source # 

Methods

showsPrec :: Int -> Pub -> ShowS #

show :: Pub -> String #

showList :: [Pub] -> ShowS #

Generic Pub Source # 

Associated Types

type Rep Pub :: * -> * #

Methods

from :: Pub -> Rep Pub x #

to :: Rep Pub x -> Pub #

FromJSON Pub Source # 
type Rep Pub Source # 

parseMessageType :: Text -> (Value -> Parser a) -> Value -> Parser a Source #

Parse the content of a message using the provided Parser, which will typically be genericParseJSON defaultOptions.

The "type" field must contain the specified Text for the parse to succeed.