Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
normandy
pleroma
Commits
c9f6eb9a
Commit
c9f6eb9a
authored
6 years ago
by
kaniini
Committed by
kaniini
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
user: implement dynamic refresh of profiles (gets rid of need for fix_ap_users task)
parent
f2727e23
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/user.ex
+19
-2
19 additions, 2 deletions
lib/pleroma/user.ex
priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs
+9
-0
9 additions, 0 deletions
...migrations/20180919060348_users_add_last_refreshed_at.exs
with
28 additions
and
2 deletions
lib/pleroma/user.ex
+
19
−
2
View file @
c9f6eb9a
...
...
@@ -22,6 +22,7 @@ defmodule Pleroma.User do
field
(
:info
,
:map
,
default:
%{})
field
(
:follower_address
,
:string
)
field
(
:search_distance
,
:float
,
virtual:
true
)
field
(
:last_refreshed_at
,
:naive_datetime
)
has_many
(
:notifications
,
Notification
)
timestamps
()
...
...
@@ -112,8 +113,12 @@ defmodule Pleroma.User do
end
def
upgrade_changeset
(
struct
,
params
\\
%{})
do
params
=
params
|>
Map
.
put
(
:last_refreshed_at
,
NaiveDateTime
.
utc_now
())
struct
|>
cast
(
params
,
[
:bio
,
:name
,
:info
,
:follower_address
,
:avatar
])
|>
cast
(
params
,
[
:bio
,
:name
,
:info
,
:follower_address
,
:avatar
,
:last_refreshed_at
])
|>
unique_constraint
(
:nickname
)
|>
validate_format
(
:nickname
,
~r/^[a-zA-Z\d]+$/
)
|>
validate_length
(
:bio
,
max:
5000
)
...
...
@@ -169,6 +174,16 @@ defmodule Pleroma.User do
end
end
def
needs_update?
(%
User
{
local:
true
}),
do
:
false
def
needs_update?
(%
User
{
local:
false
,
last_refreshed_at:
nil
}),
do
:
true
def
needs_update?
(%
User
{
local:
false
}
=
user
)
do
NaiveDateTime
.
diff
(
NaiveDateTime
.
utc_now
(),
user
.
last_refreshed_at
)
>=
86400
end
def
needs_update?
(
_
),
do
:
true
def
maybe_direct_follow
(%
User
{}
=
follower
,
%
User
{
info:
info
}
=
followed
)
do
user_config
=
Application
.
get_env
(
:pleroma
,
:user
)
deny_follow_blocked
=
Keyword
.
get
(
user_config
,
:deny_follow_blocked
)
...
...
@@ -655,7 +670,9 @@ defmodule Pleroma.User do
end
def
get_or_fetch_by_ap_id
(
ap_id
)
do
if
user
=
get_by_ap_id
(
ap_id
)
do
user
=
get_by_ap_id
(
ap_id
)
if
!is_nil
(
user
)
and
!User
.
needs_update?
(
user
)
do
user
else
ap_try
=
ActivityPub
.
make_user_from_ap_id
(
ap_id
)
...
...
This diff is collapsed.
Click to expand it.
priv/repo/migrations/20180919060348_users_add_last_refreshed_at.exs
0 → 100644
+
9
−
0
View file @
c9f6eb9a
defmodule
Pleroma
.
Repo
.
Migrations
.
UsersAddLastRefreshedAt
do
use
Ecto
.
Migration
def
change
do
alter
table
(
:users
)
do
add
:last_refreshed_at
,
:naive_datetime
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment