common api: implement scrobbling
This commit is contained in:
parent
172c74a77b
commit
2c82d8603b
2 changed files with 57 additions and 0 deletions
|
|
@ -212,6 +212,24 @@ defmodule Pleroma.Web.CommonAPI do
|
|||
|> check_expiry_date()
|
||||
end
|
||||
|
||||
def listen(user, %{"title" => _} = data) do
|
||||
with visibility <- data["visibility"] || "public",
|
||||
{to, cc} <- get_to_and_cc(user, [], nil, visibility, nil),
|
||||
listen_data <-
|
||||
Map.take(data, ["album", "artist", "title", "length"])
|
||||
|> Map.put("type", "Audio"),
|
||||
{:ok, activity} <-
|
||||
ActivityPub.listen(%{
|
||||
actor: user,
|
||||
to: to,
|
||||
object: listen_data,
|
||||
context: Utils.generate_context_id(),
|
||||
additional: %{cc: cc}
|
||||
}) do
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
||||
def post(user, %{"status" => _} = data) do
|
||||
with {:ok, draft} <- Pleroma.Web.CommonAPI.ActivityDraft.create(user, data) do
|
||||
draft.changes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue