projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix
[akkoma]
/
lib
/
pleroma
/
activity.ex
diff --git
a/lib/pleroma/activity.ex
b/lib/pleroma/activity.ex
index 480b261cfdae0e2615e612b675d3022aaef43d7e..6ca05f74e061ce4739b52fe592db979cc92408b5 100644
(file)
--- a/
lib/pleroma/activity.ex
+++ b/
lib/pleroma/activity.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Activity do
@@
-12,6
+12,7
@@
defmodule Pleroma.Activity do
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Repo
+ alias Pleroma.ReportNote
alias Pleroma.ThreadMute
alias Pleroma.User
alias Pleroma.ThreadMute
alias Pleroma.User
@@
-29,7
+30,8
@@
defmodule Pleroma.Activity do
"Follow" => "follow",
"Announce" => "reblog",
"Like" => "favourite",
"Follow" => "follow",
"Announce" => "reblog",
"Like" => "favourite",
- "Move" => "move"
+ "Move" => "move",
+ "EmojiReact" => "pleroma:emoji_reaction"
}
@mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types,
}
@mastodon_to_ap_notification_types for {k, v} <- @mastodon_notification_types,
@@
-48,6
+50,8
@@
defmodule Pleroma.Activity do
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)
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)
+ # This is a fake relation, do not use outside of with_preloaded_report_notes
+ has_many(:report_notes, ReportNote)
has_many(:notifications, Notification, on_delete: :delete_all)
# Attention: this is a fake relation, don't try to preload it blindly and expect it to work!
has_many(:notifications, Notification, on_delete: :delete_all)
# Attention: this is a fake relation, don't try to preload it blindly and expect it to work!
@@
-114,6
+118,16
@@
defmodule Pleroma.Activity do
def with_preloaded_bookmark(query, _), do: query
def with_preloaded_bookmark(query, _), do: query
+ def with_preloaded_report_notes(query) do
+ from([a] in query,
+ left_join: r in ReportNote,
+ on: a.id == r.activity_id,
+ preload: [report_notes: r]
+ )
+ end
+
+ def with_preloaded_report_notes(query, _), do: query
+
def with_set_thread_muted_field(query, %User{} = user) do
from([a] in query,
left_join: tm in ThreadMute,
def with_set_thread_muted_field(query, %User{} = user) do
from([a] in query,
left_join: tm in ThreadMute,
@@
-294,14
+308,19
@@
defmodule Pleroma.Activity do
|> where([a], fragment("? ->> 'state' = 'pending'", a.data))
end
|> where([a], fragment("? ->> 'state' = 'pending'", a.data))
end
+ def following_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
+ Queries.by_type("Follow")
+ |> where([a], fragment("?->>'state' = 'pending'", a.data))
+ |> where([a], a.actor == ^ap_id)
+ |> Repo.all()
+ end
+
def restrict_deactivated_users(query) do
deactivated_users =
def restrict_deactivated_users(query) do
deactivated_users =
- from(u in User.Query.build(
deactivated: true
), select: u.ap_id)
+ from(u in User.Query.build(
%{deactivated: true}
), select: u.ap_id)
|> Repo.all()
|> Repo.all()
- from(activity in query,
- where: activity.actor not in ^deactivated_users
- )
+ Activity.Queries.exclude_authors(query, deactivated_users)
end
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
end
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search