Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
824d1b88
Unverified
Commit
824d1b88
authored
4 years ago
by
Takeshi Umeda
Committed by
GitHub
4 years ago
Browse files
Options
Download
Plain Diff
Merge branch 'master' into feature-circles
parents
6358072b
c747883d
Changes
905
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
app/controllers/api/v1/blocks_controller.rb
+2
-0
app/controllers/api/v1/blocks_controller.rb
app/controllers/api/v1/bookmarks_controller.rb
+2
-5
app/controllers/api/v1/bookmarks_controller.rb
app/controllers/api/v1/conversations_controller.rb
+1
-1
app/controllers/api/v1/conversations_controller.rb
app/controllers/api/v1/crypto/encrypted_messages_controller.rb
+1
-1
...ontrollers/api/v1/crypto/encrypted_messages_controller.rb
app/controllers/api/v1/endorsements_controller.rb
+1
-1
app/controllers/api/v1/endorsements_controller.rb
app/controllers/api/v1/favourites_controller.rb
+2
-5
app/controllers/api/v1/favourites_controller.rb
app/controllers/api/v1/featured_tags/suggestions_controller.rb
+4
-4
...ontrollers/api/v1/featured_tags/suggestions_controller.rb
app/controllers/api/v1/follow_requests_controller.rb
+2
-2
app/controllers/api/v1/follow_requests_controller.rb
app/controllers/api/v1/instances/peers_controller.rb
+1
-1
app/controllers/api/v1/instances/peers_controller.rb
app/controllers/api/v1/lists/accounts_controller.rb
+2
-2
app/controllers/api/v1/lists/accounts_controller.rb
app/controllers/api/v1/lists_controller.rb
+1
-1
app/controllers/api/v1/lists_controller.rb
app/controllers/api/v1/mutes_controller.rb
+3
-1
app/controllers/api/v1/mutes_controller.rb
app/controllers/api/v1/notifications_controller.rb
+5
-7
app/controllers/api/v1/notifications_controller.rb
app/controllers/api/v1/push/subscriptions_controller.rb
+1
-1
app/controllers/api/v1/push/subscriptions_controller.rb
app/controllers/api/v1/scheduled_statuses_controller.rb
+1
-1
app/controllers/api/v1/scheduled_statuses_controller.rb
app/controllers/api/v1/statuses/bookmarks_controller.rb
+12
-2
app/controllers/api/v1/statuses/bookmarks_controller.rb
app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb
+1
-0
...lers/api/v1/statuses/favourited_by_accounts_controller.rb
app/controllers/api/v1/statuses/favourites_controller.rb
+13
-2
app/controllers/api/v1/statuses/favourites_controller.rb
app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb
+1
-1
...llers/api/v1/statuses/reblogged_by_accounts_controller.rb
app/controllers/api/v1/statuses_controller.rb
+1
-0
app/controllers/api/v1/statuses_controller.rb
with
57 additions
and
38 deletions
+57
-38
app/controllers/api/v1/blocks_controller.rb
+
2
-
0
View file @
824d1b88
...
...
@@ -18,6 +18,8 @@ class Api::V1::BlocksController < Api::BaseController
def
paginated_blocks
@paginated_blocks
||=
Block
.
eager_load
(
target_account: :account_stat
)
.
joins
(
:target_account
)
.
merge
(
Account
.
without_suspended
)
.
where
(
account:
current_account
)
.
paginate_by_max_id
(
limit_param
(
DEFAULT_ACCOUNTS_LIMIT
),
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/bookmarks_controller.rb
+
2
-
5
View file @
824d1b88
...
...
@@ -17,14 +17,11 @@ class Api::V1::BookmarksController < Api::BaseController
end
def
cached_bookmarks
cache_collection
(
Status
.
reorder
(
nil
).
joins
(
:bookmarks
).
merge
(
results
),
Status
)
cache_collection
(
results
.
map
(
&
:status
),
Status
)
end
def
results
@_results
||=
account_bookmarks
.
paginate_by_id
(
@_results
||=
account_bookmarks
.
eager_load
(
:status
).
to_a_
paginate
d
_by_id
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
)
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/conversations_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -32,7 +32,7 @@ class Api::V1::ConversationsController < Api::BaseController
def
paginated_conversations
AccountConversation
.
where
(
account:
current_account
)
.
paginate_by_id
(
limit_param
(
LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
.
to_a_
paginate
d
_by_id
(
limit_param
(
LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
end
def
insert_pagination_headers
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/crypto/encrypted_messages_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -26,7 +26,7 @@ class Api::V1::Crypto::EncryptedMessagesController < Api::BaseController
end
def
set_encrypted_messages
@encrypted_messages
=
@current_device
.
encrypted_messages
.
paginate_by_id
(
limit_param
(
LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
@encrypted_messages
=
@current_device
.
encrypted_messages
.
to_a_
paginate
d
_by_id
(
limit_param
(
LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
end
def
insert_pagination_headers
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/endorsements_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -25,7 +25,7 @@ class Api::V1::EndorsementsController < Api::BaseController
end
def
endorsed_accounts
current_account
.
endorsed_accounts
.
includes
(
:account_stat
)
current_account
.
endorsed_accounts
.
includes
(
:account_stat
)
.
without_suspended
end
def
insert_pagination_headers
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/favourites_controller.rb
+
2
-
5
View file @
824d1b88
...
...
@@ -17,14 +17,11 @@ class Api::V1::FavouritesController < Api::BaseController
end
def
cached_favourites
cache_collection
(
Status
.
reorder
(
nil
).
joins
(
:favourites
).
merge
(
results
),
Status
)
cache_collection
(
results
.
map
(
&
:status
),
Status
)
end
def
results
@_results
||=
account_favourites
.
paginate_by_id
(
@_results
||=
account_favourites
.
eager_load
(
:status
).
to_a_
paginate
d
_by_id
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
)
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/featured_tags/suggestions_controller.rb
+
4
-
4
View file @
824d1b88
...
...
@@ -3,15 +3,15 @@
class
Api::V1::FeaturedTags::SuggestionsController
<
Api
::
BaseController
before_action
->
{
doorkeeper_authorize!
:read
,
:'read:accounts'
},
only: :index
before_action
:require_user!
before_action
:set_
most
_used_tags
,
only: :index
before_action
:set_
recently
_used_tags
,
only: :index
def
index
render
json:
@
most
_used_tags
,
each_serializer:
REST
::
TagSerializer
render
json:
@
recently
_used_tags
,
each_serializer:
REST
::
TagSerializer
end
private
def
set_
most
_used_tags
@
most
_used_tags
=
Tag
.
most
_used
(
current_account
).
where
.
not
(
id:
current_account
.
featured_tags
).
limit
(
10
)
def
set_
recently
_used_tags
@
recently
_used_tags
=
Tag
.
recently
_used
(
current_account
).
where
.
not
(
id:
current_account
.
featured_tags
).
limit
(
10
)
end
end
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/follow_requests_controller.rb
+
2
-
2
View file @
824d1b88
...
...
@@ -13,7 +13,7 @@ class Api::V1::FollowRequestsController < Api::BaseController
def
authorize
AuthorizeFollowService
.
new
.
call
(
account
,
current_account
)
NotifyService
.
new
.
call
(
current_account
,
Follow
.
find_by
(
account:
account
,
target_account:
current_account
))
NotifyService
.
new
.
call
(
current_account
,
:follow
,
Follow
.
find_by
(
account:
account
,
target_account:
current_account
))
render
json:
account
,
serializer:
REST
::
RelationshipSerializer
,
relationships:
relationships
end
...
...
@@ -37,7 +37,7 @@ class Api::V1::FollowRequestsController < Api::BaseController
end
def
default_accounts
Account
.
includes
(
:follow_requests
,
:account_stat
).
references
(
:follow_requests
)
Account
.
without_suspended
.
includes
(
:follow_requests
,
:account_stat
).
references
(
:follow_requests
)
end
def
paginated_follow_requests
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/instances/peers_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -8,7 +8,7 @@ class Api::V1::Instances::PeersController < Api::BaseController
def
index
expires_in
1
.
day
,
public:
true
render_with_cache
(
expires_in:
1
.
day
)
{
Account
.
remote
.
domain
s
}
render_with_cache
(
expires_in:
1
.
day
)
{
Instance
.
where
.
not
(
domain:
DomainBlock
.
select
(
:domain
)).
pluck
(
:
domain
)
}
end
private
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/lists/accounts_controller.rb
+
2
-
2
View file @
824d1b88
...
...
@@ -37,9 +37,9 @@ class Api::V1::Lists::AccountsController < Api::BaseController
def
load_accounts
if
unlimited?
@list
.
accounts
.
includes
(
:account_stat
).
all
@list
.
accounts
.
without_suspended
.
includes
(
:account_stat
).
all
else
@list
.
accounts
.
includes
(
:account_stat
).
paginate_by_max_id
(
limit_param
(
DEFAULT_ACCOUNTS_LIMIT
),
params
[
:max_id
],
params
[
:since_id
])
@list
.
accounts
.
without_suspended
.
includes
(
:account_stat
).
paginate_by_max_id
(
limit_param
(
DEFAULT_ACCOUNTS_LIMIT
),
params
[
:max_id
],
params
[
:since_id
])
end
end
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/lists_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -38,6 +38,6 @@ class Api::V1::ListsController < Api::BaseController
end
def
list_params
params
.
permit
(
:title
)
params
.
permit
(
:title
,
:replies_policy
)
end
end
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/mutes_controller.rb
+
3
-
1
View file @
824d1b88
...
...
@@ -7,7 +7,7 @@ class Api::V1::MutesController < Api::BaseController
def
index
@accounts
=
load_accounts
render
json:
@accounts
,
each_serializer:
REST
::
AccountSerializer
render
json:
@accounts
,
each_serializer:
REST
::
Muted
AccountSerializer
end
private
...
...
@@ -18,6 +18,8 @@ class Api::V1::MutesController < Api::BaseController
def
paginated_mutes
@paginated_mutes
||=
Mute
.
eager_load
(
:target_account
)
.
joins
(
:target_account
)
.
merge
(
Account
.
without_suspended
)
.
where
(
account:
current_account
)
.
paginate_by_max_id
(
limit_param
(
DEFAULT_ACCOUNTS_LIMIT
),
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/notifications_controller.rb
+
5
-
7
View file @
824d1b88
...
...
@@ -14,7 +14,7 @@ class Api::V1::NotificationsController < Api::BaseController
end
def
show
@notification
=
current_account
.
notifications
.
find
(
params
[
:id
])
@notification
=
current_account
.
notifications
.
without_suspended
.
find
(
params
[
:id
])
render
json:
@notification
,
serializer:
REST
::
NotificationSerializer
end
...
...
@@ -31,18 +31,16 @@ class Api::V1::NotificationsController < Api::BaseController
private
def
load_notifications
cache_collection
paginated_notifications
,
Notification
end
def
paginated_notifications
browserable_account_notifications
.
paginate_by_id
(
cache_collection_paginated_by_id
(
browserable_account_notifications
,
Notification
,
limit_param
(
DEFAULT_NOTIFICATIONS_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
)
)
end
def
browserable_account_notifications
current_account
.
notifications
.
browserable
(
exclude_types
,
from_account
)
current_account
.
notifications
.
without_suspended
.
browserable
(
exclude_types
,
from_account
)
end
def
target_statuses_from_notifications
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/push/subscriptions_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -52,6 +52,6 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController
def
data_params
return
{}
if
params
[
:data
].
blank?
params
.
require
(
:data
).
permit
(
alerts:
[
:follow
,
:follow_request
,
:favourite
,
:reblog
,
:mention
,
:poll
])
params
.
require
(
:data
).
permit
(
alerts:
[
:follow
,
:follow_request
,
:favourite
,
:reblog
,
:mention
,
:poll
,
:status
])
end
end
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/scheduled_statuses_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -32,7 +32,7 @@ class Api::V1::ScheduledStatusesController < Api::BaseController
private
def
set_statuses
@statuses
=
current_account
.
scheduled_statuses
.
paginate_by_id
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
@statuses
=
current_account
.
scheduled_statuses
.
to_a_
paginate
d
_by_id
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
))
end
def
set_status
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/statuses/bookmarks_controller.rb
+
12
-
2
View file @
824d1b88
...
...
@@ -5,7 +5,7 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController
before_action
->
{
doorkeeper_authorize!
:write
,
:'write:bookmarks'
}
before_action
:require_user!
before_action
:set_status
before_action
:set_status
,
only:
[
:create
]
def
create
current_account
.
bookmarks
.
find_or_create_by!
(
account:
current_account
,
status:
@status
)
...
...
@@ -13,10 +13,20 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController
end
def
destroy
bookmark
=
current_account
.
bookmarks
.
find_by
(
status:
@status
)
bookmark
=
current_account
.
bookmarks
.
find_by
(
status_id:
params
[
:status_id
])
if
bookmark
@status
=
bookmark
.
status
else
@status
=
Status
.
find
(
params
[
:status_id
])
authorize
@status
,
:show?
end
bookmark
&
.
destroy!
render
json:
@status
,
serializer:
REST
::
StatusSerializer
,
relationships:
StatusRelationshipsPresenter
.
new
([
@status
],
current_account
.
id
,
bookmarks_map:
{
@status
.
id
=>
false
})
rescue
Mastodon
::
NotPermittedError
not_found
end
private
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb
+
1
-
0
View file @
824d1b88
...
...
@@ -22,6 +22,7 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
def
default_accounts
Account
.
without_suspended
.
includes
(
:favourites
,
:account_stat
)
.
references
(
:favourites
)
.
where
(
favourites:
{
status_id:
@status
.
id
})
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/statuses/favourites_controller.rb
+
13
-
2
View file @
824d1b88
...
...
@@ -5,7 +5,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
before_action
->
{
doorkeeper_authorize!
:write
,
:'write:favourites'
}
before_action
:require_user!
before_action
:set_status
before_action
:set_status
,
only:
[
:create
]
def
create
FavouriteService
.
new
.
call
(
current_account
,
@status
)
...
...
@@ -13,8 +13,19 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
end
def
destroy
UnfavouriteWorker
.
perform_async
(
current_account
.
id
,
@status
.
id
)
fav
=
current_account
.
favourites
.
find_by
(
status_id:
params
[
:status_id
])
if
fav
@status
=
fav
.
status
UnfavouriteWorker
.
perform_async
(
current_account
.
id
,
@status
.
id
)
else
@status
=
Status
.
find
(
params
[
:status_id
])
authorize
@status
,
:show?
end
render
json:
@status
,
serializer:
REST
::
StatusSerializer
,
relationships:
StatusRelationshipsPresenter
.
new
([
@status
],
current_account
.
id
,
favourites_map:
{
@status
.
id
=>
false
})
rescue
Mastodon
::
NotPermittedError
not_found
end
private
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb
+
1
-
1
View file @
824d1b88
...
...
@@ -21,7 +21,7 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
end
def
default_accounts
Account
.
includes
(
:statuses
,
:account_stat
).
references
(
:statuses
)
Account
.
without_suspended
.
includes
(
:statuses
,
:account_stat
).
references
(
:statuses
)
end
def
paginated_statuses
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/statuses_controller.rb
+
1
-
0
View file @
824d1b88
...
...
@@ -59,6 +59,7 @@ class Api::V1::StatusesController < Api::BaseController
@status
.
discard
RemovalWorker
.
perform_async
(
@status
.
id
,
redraft:
true
)
@status
.
account
.
statuses_count
=
@status
.
account
.
statuses_count
-
1
render
json:
@status
,
serializer:
REST
::
StatusSerializer
,
source_requested:
true
end
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
6
7
…
46
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets