projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
activitypub: transmogrifier: unify mention extraction
[akkoma]
/
lib
/
pleroma
/
user.ex
diff --git
a/lib/pleroma/user.ex
b/lib/pleroma/user.ex
index db6f96daa43dbc4f832663b6684de82b8305ede2..260d904bcf65bd59800ac9572de8a80a598b3bd4 100644
(file)
--- a/
lib/pleroma/user.ex
+++ b/
lib/pleroma/user.ex
@@
-4,7
+4,7
@@
defmodule Pleroma.User do
import Ecto.{Changeset, Query}
alias Pleroma.{Repo, User, Object, Web, Activity, Notification}
alias Comeonin.Pbkdf2
import Ecto.{Changeset, Query}
alias Pleroma.{Repo, User, Object, Web, Activity, Notification}
alias Comeonin.Pbkdf2
- alias Pleroma.Web.{OStatus, Websub}
+ alias Pleroma.Web.{OStatus, Websub
, OAuth
}
alias Pleroma.Web.ActivityPub.{Utils, ActivityPub}
schema "users" do
alias Pleroma.Web.ActivityPub.{Utils, ActivityPub}
schema "users" do
@@
-42,6
+42,10
@@
defmodule Pleroma.User do
end
end
end
end
+ def profile_url(%User{info: %{"source_data" => %{"url" => url}}}), do: url
+ def profile_url(%User{ap_id: ap_id}), do: ap_id
+ def profile_url(_), do: nil
+
def ap_id(%User{nickname: nickname}) do
"#{Web.base_url()}/users/#{nickname}"
end
def ap_id(%User{nickname: nickname}) do
"#{Web.base_url()}/users/#{nickname}"
end
@@
-132,6
+136,9
@@
defmodule Pleroma.User do
|> validate_required([:password, :password_confirmation])
|> validate_confirmation(:password)
|> validate_required([:password, :password_confirmation])
|> validate_confirmation(:password)
+ OAuth.Token.delete_user_tokens(struct)
+ OAuth.Authorization.delete_user_authorizations(struct)
+
if changeset.valid? do
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
if changeset.valid? do
hashed = Pbkdf2.hashpwsalt(changeset.changes[:password])
@@
-288,6
+295,7
@@
defmodule Pleroma.User do
def invalidate_cache(user) do
Cachex.del(:user_cache, "ap_id:#{user.ap_id}")
Cachex.del(:user_cache, "nickname:#{user.nickname}")
def invalidate_cache(user) do
Cachex.del(:user_cache, "ap_id:#{user.ap_id}")
Cachex.del(:user_cache, "nickname:#{user.nickname}")
+ Cachex.del(:user_cache, "user_info:#{user.id}")
end
def get_cached_by_ap_id(ap_id) do
end
def get_cached_by_ap_id(ap_id) do
@@
-456,15
+464,28
@@
defmodule Pleroma.User do
update_and_set_cache(cs)
end
update_and_set_cache(cs)
end
- def get_notified_from_activity_query(to) do
+ def get_notified_from_activity_query(to
, false
) do
from(
u in User,
from(
u in User,
- where: u.ap_id in ^to,
+ where: u.ap_id in ^to
+ )
+ end
+
+ def get_notified_from_activity_query(to, true) do
+ query = get_notified_from_activity_query(to, false)
+
+ from(
+ u in query,
where: u.local == true
)
end
where: u.local == true
)
end
- def get_notified_from_activity(%Activity{recipients: to, data: %{"type" => "Announce"} = data}) do
+ def get_notified_from_activity(activity, local_only \\ true)
+
+ def get_notified_from_activity(
+ %Activity{data: %{"type" => "Announce", "to" => to} = data},
+ local_only
+ ) do
object = Object.normalize(data["object"])
actor = User.get_cached_by_ap_id(data["actor"])
object = Object.normalize(data["object"])
actor = User.get_cached_by_ap_id(data["actor"])
@@
-477,17
+498,19
@@
defmodule Pleroma.User do
end
|> Enum.uniq()
end
|> Enum.uniq()
- query = get_notified_from_activity_query(to)
+ query = get_notified_from_activity_query(to
, local_only
)
Repo.all(query)
end
Repo.all(query)
end
- def get_notified_from_activity(%Activity{
recipients: to}
) do
- query = get_notified_from_activity_query(to)
+ def get_notified_from_activity(%Activity{
data: %{"to" => to}}, local_only
) do
+ query = get_notified_from_activity_query(to
, local_only
)
Repo.all(query)
end
Repo.all(query)
end
+ def get_notified_from_activity(_, _), do: []
+
def get_recipients_from_activity(%Activity{recipients: to}) do
query =
from(
def get_recipients_from_activity(%Activity{recipients: to}) do
query =
from(
@@
-615,8
+638,8
@@
defmodule Pleroma.User do
)
end
)
end
- def deactivate(%User{} = user) do
- new_info = Map.put(user.info, "deactivated",
true
)
+ def deactivate(%User{} = user
, status \\ true
) do
+ new_info = Map.put(user.info, "deactivated",
status
)
cs = User.info_changeset(user, %{info: new_info})
update_and_set_cache(cs)
end
cs = User.info_changeset(user, %{info: new_info})
update_and_set_cache(cs)
end
@@
-649,7
+672,7
@@
defmodule Pleroma.User do
end
end)
end
end)
- :ok
+ {:ok, user}
end
def html_filter_policy(%User{info: %{"no_rich_text" => true}}) do
end
def html_filter_policy(%User{info: %{"no_rich_text" => true}}) do