1
0
Fork 0

Load even more data from accounts

This commit is contained in:
Ryan Fox 2021-01-11 08:47:19 +00:00
parent 5da1d8882c
commit 628ac848d3
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
2 changed files with 59 additions and 0 deletions

View File

@ -7,6 +7,8 @@ module Mastodon.Decoder
, contextDecoder
, decodeWebSocketMessage
, decodeClients
, emojiDecoder
, fieldDecoder
, mastodonErrorDecoder
, mentionDecoder
, notificationDecoder
@ -41,25 +43,51 @@ accessTokenDecoder registration =
|> Pipe.hardcoded registration.server
|> Pipe.required "access_token" Decode.string
emojiDecoder : Decode.Decoder Emoji
emojiDecoder =
Pipe.decode Emoji
|> Pipe.required "shortcode" Decode.string
|> Pipe.required "url" Decode.string
|> Pipe.required "static_url" Decode.string
|> Pipe.required "visible_in_picker" Decode.bool
fieldDecoder : Decode.Decoder Field
fieldDecoder =
Pipe.decode Field
|> Pipe.optional "name" Decode.string ""
|> Pipe.optional "value" Decode.string ""
|> Pipe.optional "verified_at" Decode.string ""
sourceDecoder : Decode.Decoder Source
sourceDecoder =
Pipe.decode Source
|> Pipe.optional "privacy" Decode.string "public"
|> Pipe.optional "sensitive" Decode.bool False
|> Pipe.optional "language" Decode.string ""
|> Pipe.optional "note" Decode.string ""
|> Pipe.optional "fields" (Decode.list fieldDecoder) []
|> Pipe.optional "follow_requests_count" Decode.int 0
accountDecoder : Decode.Decoder Account
accountDecoder =
Pipe.decode Account
|> Pipe.required "acct" Decode.string
|> Pipe.required "avatar" Decode.string
|> Pipe.required "avatar_static" Decode.string
|> Pipe.required "created_at" Decode.string
|> Pipe.required "last_status_at" Decode.string
|> Pipe.required "display_name" Decode.string
|> Pipe.required "followers_count" Decode.int
|> Pipe.required "following_count" Decode.int
|> Pipe.required "header" Decode.string
|> Pipe.required "header_static" Decode.string
|> Pipe.required "id" idDecoder
|> Pipe.required "locked" Decode.bool
|> Pipe.required "bot" Decode.bool
|> Pipe.required "note" Decode.string
|> Pipe.required "statuses_count" Decode.int
|> Pipe.required "url" Decode.string
@ -68,7 +96,12 @@ accountDecoder =
{ privacy = "public"
, sensitive = False
, language = ""
, note = ""
, fields = []
, follow_requests_count = 0
}
|> Pipe.optional "emojis" (Decode.list emojiDecoder) []
|> Pipe.optional "fields" (Decode.list fieldDecoder) []
applicationDecoder : Decode.Decoder Application

View File

@ -8,7 +8,9 @@ module Mastodon.Model
, Attachment
, Client
, Context
, Emoji
, Error(..)
, Field
, Mention
, Notification
, NotificationAggregate
@ -82,21 +84,42 @@ type alias AppRegistration =
}
type alias Emoji =
{ shortcode : String
, url : String
, static_url : String
, visible_in_picker : Bool
}
type alias Field =
{ name : String
, value : String
, verified_at : String
}
type alias Account =
{ acct : String
, avatar : String
, avatar_static : String
, created_at : String
, last_status_at : String
, display_name : String
, followers_count : Int
, following_count : Int
, header : String
, header_static : String
, id : AccountId
, locked : Bool
, bot : Bool
, note : String
, statuses_count : Int
, url : String
, username : String
, source : Source
, emojis : List Emoji
, fields : List Field
}
@ -194,6 +217,9 @@ type alias Source =
{ privacy : String
, sensitive : Bool
, language : String
, note : String
, fields : List Field
, follow_requests_count : Int
}