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
Ivan Tashkinov
pleroma
Commits
4656cb9b
Commit
4656cb9b
authored
7 years ago
by
eal
Browse files
Options
Downloads
Patches
Plain Diff
TwitterAPI user view: add blocks.
parent
3bbefd0a
Branches
fix-tootdon-image-uploads
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/twitter_api/views/user_view.ex
+6
-0
6 additions, 0 deletions
lib/pleroma/web/twitter_api/views/user_view.ex
test/web/twitter_api/views/user_view_test.exs
+33
-0
33 additions, 0 deletions
test/web/twitter_api/views/user_view_test.exs
with
39 additions
and
0 deletions
lib/pleroma/web/twitter_api/views/user_view.ex
+
6
−
0
View file @
4656cb9b
...
...
@@ -21,6 +21,11 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
else
false
end
statusnet_blocking
=
if
assigns
[
:for
]
do
User
.
blocks?
(
assigns
[
:for
],
user
)
else
false
end
user_info
=
User
.
get_cached_user_info
(
user
)
...
...
@@ -30,6 +35,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"favourites_count"
=>
0
,
"followers_count"
=>
user_info
[
:follower_count
],
"following"
=>
following
,
"statusnet_blocking"
=>
statusnet_blocking
,
"friends_count"
=>
user_info
[
:following_count
],
"id"
=>
user
.
id
,
"name"
=>
user
.
name
,
...
...
This diff is collapsed.
Click to expand it.
test/web/twitter_api/views/user_view_test.exs
+
33
−
0
View file @
4656cb9b
...
...
@@ -50,6 +50,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"profile_image_url_profile_size"
=>
image
,
"profile_image_url_original"
=>
image
,
"following"
=>
false
,
"statusnet_blocking"
=>
false
,
"rights"
=>
%{},
"statusnet_profile_url"
=>
user
.
ap_id
,
"cover_photo"
=>
nil
,
...
...
@@ -78,6 +79,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"profile_image_url_profile_size"
=>
image
,
"profile_image_url_original"
=>
image
,
"following"
=>
true
,
"statusnet_blocking"
=>
false
,
"rights"
=>
%{},
"statusnet_profile_url"
=>
user
.
ap_id
,
"cover_photo"
=>
nil
,
...
...
@@ -86,4 +88,35 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
assert
represented
==
UserView
.
render
(
"show.json"
,
%{
user:
user
,
for:
follower
})
end
test
"A blocked user for the blocker"
,
%{
user:
user
}
do
user
=
insert
(
:user
)
blocker
=
insert
(
:user
)
User
.
block
(
blocker
,
user
)
image
=
"https://placehold.it/48x48"
represented
=
%{
"id"
=>
user
.
id
,
"name"
=>
user
.
name
,
"screen_name"
=>
user
.
nickname
,
"description"
=>
HtmlSanitizeEx
.
strip_tags
(
user
.
bio
),
"created_at"
=>
user
.
inserted_at
|>
Utils
.
format_naive_asctime
,
"favourites_count"
=>
0
,
"statuses_count"
=>
0
,
"friends_count"
=>
0
,
"followers_count"
=>
0
,
"profile_image_url"
=>
image
,
"profile_image_url_https"
=>
image
,
"profile_image_url_profile_size"
=>
image
,
"profile_image_url_original"
=>
image
,
"following"
=>
false
,
"statusnet_blocking"
=>
true
,
"rights"
=>
%{},
"statusnet_profile_url"
=>
user
.
ap_id
,
"cover_photo"
=>
nil
,
"background_image"
=>
nil
}
blocker
=
Repo
.
get
(
User
,
blocker
.
id
)
assert
represented
==
UserView
.
render
(
"show.json"
,
%{
user:
user
,
for:
blocker
})
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