X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Factivity.ex;h=afd09982fcd45211249c0c4cac75f80fefaf65db;hb=dffde6631d105949b62c1ff27c22fefcb873b2e8;hp=d7e31b6b4cdfe92a42ff59abe1ee30bf7b77888d;hpb=9f417fd5e9893b095041702a6bd0190c7f1d7f22;p=akkoma diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index d7e31b6b4..afd09982f 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -6,7 +6,8 @@ defmodule Pleroma.Activity do schema "activities" do field :data, :map field :local, :boolean, default: true - has_many :notifications, Notification + field :actor, :string + has_many :notifications, Notification, on_delete: :delete_all timestamps() end @@ -38,7 +39,7 @@ defmodule Pleroma.Activity do def get_create_activity_by_object_ap_id(ap_id) do Repo.one(from activity in Activity, - where: fragment("(?)->'object'->>'id' = ?", activity.data, ^to_string(ap_id)) - and fragment("(?)->>'type' = 'Create'", activity.data)) + where: fragment("coalesce((?)->'object'->>'id', (?)->>'object') = ?", activity.data, activity.data, ^to_string(ap_id)), + where: fragment("(?)->>'type' = 'Create'", activity.data)) end end