Pleroma: Support quote posts

This commit is contained in:
Ryan Fox 2022-03-24 18:27:46 -07:00
parent 1053544ddc
commit 5566d320f5
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
3 changed files with 21 additions and 2 deletions

View File

@ -22,6 +22,7 @@ module Mastodon.Decoder
, searchResultsDecoder , searchResultsDecoder
, statusDecoder , statusDecoder
, webSocketEventDecoder , webSocketEventDecoder
, pleromaDecoder
, pollIdDecoder , pollIdDecoder
, pollOptionDecoder , pollOptionDecoder
, pollDecoder , pollDecoder
@ -262,6 +263,12 @@ idDecoder =
] ]
pleromaDecoder : Decode.Decoder Pleroma
pleromaDecoder =
Pipe.decode Pleroma
|> Pipe.optional "quote" (Decode.lazy (\_ -> Decode.nullable quoteDecoder)) Nothing
pollIdDecoder : Decode.Decoder PollId pollIdDecoder : Decode.Decoder PollId
pollIdDecoder = pollIdDecoder =
idDecoder |> Decode.map PollId idDecoder |> Decode.map PollId
@ -313,6 +320,7 @@ statusDecoder =
|> Pipe.required "uri" Decode.string |> Pipe.required "uri" Decode.string
|> Pipe.required "url" (Decode.nullable Decode.string) |> Pipe.required "url" (Decode.nullable Decode.string)
|> Pipe.required "visibility" Decode.string |> Pipe.required "visibility" Decode.string
|> Pipe.optional "pleroma" (Decode.lazy (\_ -> Decode.nullable pleromaDecoder)) Nothing
|> Pipe.optional "poll" pollDecoder |> Pipe.optional "poll" pollDecoder
{ id = PollId("") { id = PollId("")
, expired = False , expired = False

View File

@ -14,10 +14,14 @@ module Mastodon.Helper
import List.Extra exposing (groupWhile, uniqueBy) import List.Extra exposing (groupWhile, uniqueBy)
import Mastodon.Model exposing (..) import Mastodon.Model exposing (..)
extractQuote : Status -> Maybe Quote extractQuote : Status -> Maybe Quote
extractQuote status = extractQuote status =
status.quote case status.pleroma of
Just pleroma ->
pleroma.quote
Nothing->
status.quote
extractReblog : Status -> Status extractReblog : Status -> Status

View File

@ -21,6 +21,7 @@ module Mastodon.Model
, Reblog(..) , Reblog(..)
, Relationship , Relationship
, Tag , Tag
, Pleroma
, PollId(..) , PollId(..)
, PollOption , PollOption
, Poll , Poll
@ -247,6 +248,11 @@ type alias Hashtag =
} }
type alias Pleroma =
{ quote : Maybe Quote
}
type PollId type PollId
= PollId String = PollId String
@ -305,6 +311,7 @@ type alias Status =
, uri : String , uri : String
, url : Maybe String , url : Maybe String
, visibility : String , visibility : String
, pleroma : Maybe Pleroma
, poll : Poll , poll : Poll
, pinned : Bool -- Not a real value, used to show pinned indicator , pinned : Bool -- Not a real value, used to show pinned indicator
} }