From 628ac848d3c71b62bc2b87ed81bbd963625ec95e Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Mon, 11 Jan 2021 08:47:19 +0000 Subject: [PATCH] Load even more data from accounts --- src/Mastodon/Decoder.elm | 33 +++++++++++++++++++++++++++++++++ src/Mastodon/Model.elm | 26 ++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/Mastodon/Decoder.elm b/src/Mastodon/Decoder.elm index 27c1568..423fb77 100644 --- a/src/Mastodon/Decoder.elm +++ b/src/Mastodon/Decoder.elm @@ -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 diff --git a/src/Mastodon/Model.elm b/src/Mastodon/Model.elm index ddc1aae..9b055bf 100644 --- a/src/Mastodon/Model.elm +++ b/src/Mastodon/Model.elm @@ -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 }