Fix handling incoming Likes
This commit is contained in:
parent
dcadde5e37
commit
9dfb4b22e1
|
@ -60,12 +60,13 @@ defmodule Clacks.Activity do
|
|||
Repo.one(from a in __MODULE__, where: fragment("?->>'id'", a.data) == ^ap_id)
|
||||
end
|
||||
|
||||
@spec get_by_object_ap_id(object_id :: String.t()) :: t() | nil
|
||||
def get_by_object_ap_id(object_id) do
|
||||
@spec get_by_object_ap_id(object_id :: String.t(), type :: String.t()) :: t() | nil
|
||||
def get_by_object_ap_id(object_id, type) do
|
||||
__MODULE__
|
||||
|> where(
|
||||
[a],
|
||||
fragment("COALESCE(?->'object'->>'id', ?->>'object')", a.data, a.data) == ^object_id
|
||||
fragment("?->>'type'", a.data) == ^type and
|
||||
fragment("COALESCE(?->'object'->>'id', ?->>'object')", a.data, a.data) == ^object_id
|
||||
)
|
||||
|> preload_object()
|
||||
|> Repo.one()
|
||||
|
|
|
@ -75,7 +75,7 @@ defmodule Clacks.Notification do
|
|||
)
|
||||
when type in ["Announce", "Like"] do
|
||||
with %Activity{local: true, actor: local_actor_id} <-
|
||||
Activity.get_by_object_ap_id(original_object_ap_id),
|
||||
Activity.get_by_object_ap_id(original_object_ap_id, "Create"),
|
||||
%Actor{local: true} = original_activity_actor <-
|
||||
Actor.get_cached_by_ap_id(local_actor_id) do
|
||||
create(String.downcase(type), activity, original_activity_actor)
|
||||
|
|
|
@ -74,7 +74,7 @@ defmodule Clacks.Object do
|
|||
_ = Clacks.Actor.get_by_ap_id(actor)
|
||||
|
||||
activity =
|
||||
case Clacks.Activity.get_by_object_ap_id(ap_id) do
|
||||
case Clacks.Activity.get_by_object_ap_id(ap_id, "Create") do
|
||||
nil ->
|
||||
if synthesize_create do
|
||||
create = Clacks.ActivityPub.synthesized_create(data)
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule ClacksWeb.ObjectsController do
|
|||
defp redirect_to_status(conn, _params) do
|
||||
object_id = current_url(conn)
|
||||
|
||||
case Activity.get_by_object_ap_id(object_id) do
|
||||
case Activity.get_by_object_ap_id(object_id, "Create") do
|
||||
nil ->
|
||||
conn
|
||||
|> resp(404, "Not Found")
|
||||
|
|
Loading…
Reference in New Issue