diff --git a/src/grom/channel.gleam b/src/grom/channel.gleam index b9e51b6..f2114ca 100644 --- a/src/grom/channel.gleam +++ b/src/grom/channel.gleam @@ -17,6 +17,7 @@ import grom/internal/flags import grom/internal/rest import grom/internal/time_duration import grom/internal/time_rfc3339 +import grom/message.{type Message} import grom/modification.{type Modification, Skip} import grom/permission.{type Permission} import grom/user.{type User} @@ -1747,3 +1748,18 @@ pub fn trigger_typing_indicator( Ok(Nil) } + +pub fn get_pinned_messages( + client: Client, + in channel_id: String, +) -> Result(List(Message), Error) { + use response <- result.try( + client + |> rest.new_request(http.Get, "/channels/" <> channel_id <> "/pins") + |> rest.execute, + ) + + response.body + |> json.parse(using: decode.list(message.decoder())) + |> result.map_error(error.CouldNotDecode) +} diff --git a/src/grom/message.gleam b/src/grom/message.gleam index 0d32c37..c71bf4e 100644 --- a/src/grom/message.gleam +++ b/src/grom/message.gleam @@ -753,21 +753,6 @@ pub fn resolved_decoder() -> decode.Decoder(Resolved) { // PUBLIC API FUNCTIONS -------------------------------------------------------- -pub fn get_pinned( - client: Client, - in channel_id: String, -) -> Result(List(Message), Error) { - use response <- result.try( - client - |> rest.new_request(http.Get, "/channels/" <> channel_id <> "/pins") - |> rest.execute, - ) - - response.body - |> json.parse(using: decode.list(decoder())) - |> result.map_error(error.CouldNotDecode) -} - pub fn pin( client: Client, in channel_id: String,