formatting

This commit is contained in:
William Pitcock 2019-03-23 00:28:16 +00:00
parent 59518cbcd8
commit a6973a668e
3 changed files with 10 additions and 7 deletions

View File

@ -59,7 +59,8 @@ def with_preloaded_object(query) do
:inner, :inner,
[activity], [activity],
o in Object, o in Object,
on: fragment( on:
fragment(
"(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)", "(?->>'id') = COALESCE((? -> 'object'::text) ->> 'id'::text)",
o.data, o.data,
activity.data activity.data

View File

@ -63,7 +63,8 @@ def reject_follow_request(follower, followed) do
end end
def delete(activity_id, user) do def delete(activity_id, user) do
with %Activity{data: %{"object" => _}} = activity <- Activity.get_by_id_with_object(activity_id), with %Activity{data: %{"object" => _}} = activity <-
Activity.get_by_id_with_object(activity_id),
%Object{} = object <- Object.normalize(activity), %Object{} = object <- Object.normalize(activity),
true <- User.superuser?(user) || user.ap_id == object.data["actor"], true <- User.superuser?(user) || user.ap_id == object.data["actor"],
{:ok, _} <- unpin(activity_id, user), {:ok, _} <- unpin(activity_id, user),

View File

@ -17,7 +17,8 @@ defmodule Pleroma.Web.CommonAPI.Utils do
# This is a hack for twidere. # This is a hack for twidere.
def get_by_id_or_ap_id(id) do def get_by_id_or_ap_id(id) do
activity = Activity.get_by_id_with_object(id) || Activity.get_create_by_object_ap_id_with_object(id) activity =
Activity.get_by_id_with_object(id) || Activity.get_create_by_object_ap_id_with_object(id)
activity && activity &&
if activity.data["type"] == "Create" do if activity.data["type"] == "Create" do