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
e4763cd4
Commit
e4763cd4
authored
Dec 17, 2018
by
lain
Browse files
Fix tagging problems for existing instances.
parent
56735979
Pipeline
#5481
failed with stages
in 3 minutes and 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
e4763cd4
...
...
@@ -838,7 +838,7 @@ def tag(nickname, tags) when is_binary(nickname),
do
:
tag
(
User
.
get_by_nickname
(
nickname
),
tags
)
def
tag
(%
User
{}
=
user
,
tags
),
do
:
update_tags
(
user
,
Enum
.
uniq
(
user
.
tags
++
normalize_tags
(
tags
)))
do
:
update_tags
(
user
,
Enum
.
uniq
(
(
user
.
tags
||
[])
++
normalize_tags
(
tags
)))
def
untag
(
user_identifiers
,
tags
)
when
is_list
(
user_identifiers
)
do
Repo
.
transaction
(
fn
->
...
...
@@ -849,7 +849,8 @@ def untag(user_identifiers, tags) when is_list(user_identifiers) do
def
untag
(
nickname
,
tags
)
when
is_binary
(
nickname
),
do
:
untag
(
User
.
get_by_nickname
(
nickname
),
tags
)
def
untag
(%
User
{}
=
user
,
tags
),
do
:
update_tags
(
user
,
user
.
tags
--
normalize_tags
(
tags
))
def
untag
(%
User
{}
=
user
,
tags
),
do
:
update_tags
(
user
,
(
user
.
tags
||
[])
--
normalize_tags
(
tags
))
defp
update_tags
(%
User
{}
=
user
,
new_tags
)
do
{
:ok
,
updated_user
}
=
...
...
test/user_test.exs
View file @
e4763cd4
...
...
@@ -11,6 +11,23 @@ defmodule Pleroma.UserTest do
:ok
end
describe
"when tags are nil"
do
test
"tagging a user"
do
user
=
insert
(
:user
,
%{
tags:
nil
})
user
=
User
.
tag
(
user
,
[
"cool"
,
"dude"
])
assert
"cool"
in
user
.
tags
assert
"dude"
in
user
.
tags
end
test
"untagging a user"
do
user
=
insert
(
:user
,
%{
tags:
nil
})
user
=
User
.
untag
(
user
,
[
"cool"
,
"dude"
])
assert
user
.
tags
==
[]
end
end
test
"ap_id returns the activity pub id for the user"
do
user
=
UserBuilder
.
build
()
...
...
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