Merge remote-tracking branch 'upstream/develop' into feature/move-activity

This commit is contained in:
Egor Kislitsyn 2019-11-14 16:39:45 +07:00
commit 3c0abfca53
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
118 changed files with 4497 additions and 1295 deletions

View file

@ -120,6 +120,25 @@ defmodule Pleroma.Web.CommonAPI do
end
end
def react_with_emoji(id, user, emoji) do
with %Activity{} = activity <- Activity.get_by_id(id),
object <- Object.normalize(activity) do
ActivityPub.react_with_emoji(user, object, emoji)
else
_ ->
{:error, dgettext("errors", "Could not add reaction emoji")}
end
end
def unreact_with_emoji(id, user, emoji) do
with %Activity{} = reaction_activity <- Utils.get_latest_reaction(id, user, emoji) do
ActivityPub.unreact_with_emoji(user, reaction_activity.data["id"])
else
_ ->
{:error, dgettext("errors", "Could not remove reaction emoji")}
end
end
def vote(user, %{data: %{"type" => "Question"}} = object, choices) do
with :ok <- validate_not_author(object, user),
:ok <- validate_existing_votes(user, object),