Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
d26cd6c1
Commit
d26cd6c1
authored
Nov 09, 2018
by
kaniini
Browse files
user: factor out user set fetching from User.get_notified_from_activity()
parent
81d6ca17
Pipeline
#4346
passed with stages
in 9 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
d26cd6c1
...
@@ -464,15 +464,15 @@ def update_follower_count(%User{} = user) do
...
@@ -464,15 +464,15 @@ def update_follower_count(%User{} = user) do
update_and_set_cache
(
cs
)
update_and_set_cache
(
cs
)
end
end
def
get_
notified_from_activity
_query
(
to
,
false
)
do
def
get_
users_from_set
_query
(
ap_ids
,
false
)
do
from
(
from
(
u
in
User
,
u
in
User
,
where:
u
.
ap_id
in
^
to
where:
u
.
ap_id
in
^
ap_ids
)
)
end
end
def
get_
notified_from_activity
_query
(
to
,
true
)
do
def
get_
users_from_set
_query
(
ap_ids
,
true
)
do
query
=
get_
notified_from_activity
_query
(
to
,
false
)
query
=
get_
users_from_set
_query
(
ap_ids
,
false
)
from
(
from
(
u
in
query
,
u
in
query
,
...
@@ -480,6 +480,11 @@ def get_notified_from_activity_query(to, true) do
...
@@ -480,6 +480,11 @@ def get_notified_from_activity_query(to, true) do
)
)
end
end
def
get_users_from_set
(
ap_ids
,
local_only
\\
true
)
do
get_users_from_set_query
(
ap_ids
,
local_only
)
|>
Repo
.
all
()
end
def
get_notified_from_activity
(
activity
,
local_only
\\
true
)
def
get_notified_from_activity
(
activity
,
local_only
\\
true
)
def
get_notified_from_activity
(%
Activity
{
data:
%{
"to"
=>
to
}
=
data
},
local_only
)
do
def
get_notified_from_activity
(%
Activity
{
data:
%{
"to"
=>
to
}
=
data
},
local_only
)
do
...
@@ -513,9 +518,7 @@ def get_notified_from_activity(%Activity{data: %{"to" => to} = data}, local_only
...
@@ -513,9 +518,7 @@ def get_notified_from_activity(%Activity{data: %{"to" => to} = data}, local_only
(
to
++
tagged_mentions
)
(
to
++
tagged_mentions
)
|>
Enum
.
uniq
()
|>
Enum
.
uniq
()
query
=
get_notified_from_activity_query
(
to
,
local_only
)
get_users_from_set
(
to
,
local_only
)
Repo
.
all
(
query
)
end
end
def
get_notified_from_activity
(
_
,
_
),
do
:
[]
def
get_notified_from_activity
(
_
,
_
),
do
:
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment