"Create" => "mention",
"Follow" => "follow",
"Announce" => "reblog",
- "Like" => "favourite"
+ "Like" => "favourite",
+ "Move" => "move"
}
@mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types,
field(:recipients, {:array, :string}, default: [])
field(:thread_muted?, :boolean, virtual: true)
- # This is a fake relation, do not use outside of with_preloaded_user_actor/with_joined_user_actor
+ # This is a fake relation,
+ # do not use outside of with_preloaded_user_actor/with_joined_user_actor
has_one(:user_actor, User, on_delete: :nothing, foreign_key: :id)
# This is a fake relation, do not use outside of with_preloaded_bookmark/get_bookmark
has_one(:bookmark, Bookmark)
def with_joined_user_actor(query, join_type \\ :inner) do
join(query, join_type, [activity], u in User,
- on:
- fragment(
- "? = ?->>'actor'",
- u.ap_id,
- activity.data
- ),
+ on: u.ap_id == activity.actor,
as: :user_actor
)
end
end
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
+
+ def direct_conversation_id(activity, for_user) do
+ alias Pleroma.Conversation.Participation
+
+ with %{data: %{"context" => context}} when is_binary(context) <- activity,
+ %Pleroma.Conversation{} = conversation <- Pleroma.Conversation.get_for_ap_id(context),
+ %Participation{id: participation_id} <-
+ Participation.for_user_and_conversation(for_user, conversation) do
+ participation_id
+ else
+ _ -> nil
+ end
+ end
end