Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
98a2603d
Unverified
Commit
98a2603d
authored
4 years ago
by
Takeshi Umeda
Committed by
GitHub
4 years ago
Browse files
Options
Download
Plain Diff
Merge branch 'master' into feature-limited-visibility-bearcaps
parents
7cd4ed7d
087ed843
Changes
854
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
app/controllers/api/v1/crypto/encrypted_messages_controller.rb
+1
-1
...ontrollers/api/v1/crypto/encrypted_messages_controller.rb
app/controllers/api/v1/crypto/keys/claims_controller.rb
+1
-1
app/controllers/api/v1/crypto/keys/claims_controller.rb
app/controllers/api/v1/crypto/keys/queries_controller.rb
+1
-1
app/controllers/api/v1/crypto/keys/queries_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
+1
-1
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
+2
-2
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/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/timelines/public_controller.rb
+14
-15
app/controllers/api/v1/timelines/public_controller.rb
app/controllers/api/v1/timelines/tag_controller.rb
+20
-14
app/controllers/api/v1/timelines/tag_controller.rb
app/controllers/api/web/push_subscriptions_controller.rb
+2
-1
app/controllers/api/web/push_subscriptions_controller.rb
with
73 additions
and
53 deletions
+73
-53
app/controllers/api/v1/crypto/encrypted_messages_controller.rb
+
1
-
1
View file @
98a2603d
...
...
@@ -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/crypto/keys/claims_controller.rb
+
1
-
1
View file @
98a2603d
...
...
@@ -12,7 +12,7 @@ class Api::V1::Crypto::Keys::ClaimsController < Api::BaseController
private
def
set_claim_results
@claim_results
=
devices
.
map
{
|
device_params
|
::
Keys
::
ClaimService
.
new
.
call
(
current_account
,
device_params
[
:account_id
],
device_params
[
:device_id
])
}
.
compact
@claim_results
=
devices
.
filter_
map
{
|
device_params
|
::
Keys
::
ClaimService
.
new
.
call
(
current_account
,
device_params
[
:account_id
],
device_params
[
:device_id
])
}
end
def
resource_params
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/crypto/keys/queries_controller.rb
+
1
-
1
View file @
98a2603d
...
...
@@ -17,7 +17,7 @@ class Api::V1::Crypto::Keys::QueriesController < Api::BaseController
end
def
set_query_results
@query_results
=
@accounts
.
map
{
|
account
|
::
Keys
::
QueryService
.
new
.
call
(
account
)
}
.
compact
@query_results
=
@accounts
.
filter_
map
{
|
account
|
::
Keys
::
QueryService
.
new
.
call
(
account
)
}
end
def
account_ids
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/endorsements_controller.rb
+
1
-
1
View file @
98a2603d
...
...
@@ -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
+
1
-
1
View file @
98a2603d
...
...
@@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController
end
def
results
@_results
||=
account_favourites
.
eager_load
(
:status
).
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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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
+
2
-
2
View file @
98a2603d
...
...
@@ -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
...
...
@@ -40,7 +40,7 @@ class Api::V1::NotificationsController < Api::BaseController
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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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/favourited_by_accounts_controller.rb
+
1
-
0
View file @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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 @
98a2603d
...
...
@@ -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/timelines/public_controller.rb
+
14
-
15
View file @
98a2603d
...
...
@@ -20,26 +20,25 @@ class Api::V1::Timelines::PublicController < Api::BaseController
end
def
cached_public_statuses_page
cache_collection_paginated_by_id
(
public_statuses
,
Status
,
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
)
)
cache_collection
(
public_statuses
,
Status
)
end
def
public_statuses
statuses
=
public_timeline_statuses
if
truthy_param?
(
:only_media
)
statuses
.
joins
(
:media_attachments
).
group
(
:id
)
else
statuses
end
public_feed
.
get
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params
[
:max_id
],
params
[
:since_id
],
params
[
:min_id
]
)
end
def
public_timeline_statuses
Status
.
as_public_timeline
(
current_account
,
truthy_param?
(
:remote
)
?
:remote
:
truthy_param?
(
:local
))
def
public_feed
PublicFeed
.
new
(
current_account
,
local:
truthy_param?
(
:local
),
remote:
truthy_param?
(
:remote
),
only_media:
truthy_param?
(
:only_media
)
)
end
def
insert_pagination_headers
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/v1/timelines/tag_controller.rb
+
20
-
14
View file @
98a2603d
...
...
@@ -20,23 +20,29 @@ class Api::V1::Timelines::TagController < Api::BaseController
end
def
cached_tagged_statuses
if
@tag
.
nil?
[]
else
statuses
=
tag_timeline_statuses
statuses
=
statuses
.
joins
(
:media_attachments
)
if
truthy_param?
(
:only_media
)
cache_collection_paginated_by_id
(
statuses
,
Status
,
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params_slice
(
:max_id
,
:since_id
,
:min_id
)
)
end
@tag
.
nil?
?
[]
:
cache_collection
(
tag_timeline_statuses
,
Status
)
end
def
tag_timeline_statuses
HashtagQueryService
.
new
.
call
(
@tag
,
params
.
slice
(
:any
,
:all
,
:none
),
current_account
,
truthy_param?
(
:local
))
tag_feed
.
get
(
limit_param
(
DEFAULT_STATUSES_LIMIT
),
params
[
:max_id
],
params
[
:since_id
],
params
[
:min_id
]
)
end
def
tag_feed
TagFeed
.
new
(
@tag
,
current_account
,
any:
params
[
:any
],
all:
params
[
:all
],
none:
params
[
:none
],
local:
truthy_param?
(
:local
),
remote:
truthy_param?
(
:remote
),
only_media:
truthy_param?
(
:only_media
)
)
end
def
insert_pagination_headers
...
...
This diff is collapsed.
Click to expand it.
app/controllers/api/web/push_subscriptions_controller.rb
+
2
-
1
View file @
98a2603d
...
...
@@ -22,6 +22,7 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
reblog:
alerts_enabled
,
mention:
alerts_enabled
,
poll:
alerts_enabled
,
status:
alerts_enabled
,
},
}
...
...
@@ -57,6 +58,6 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
end
def
data_params
@data_params
||=
params
.
require
(
:data
).
permit
(
alerts:
[
:follow
,
:follow_request
,
:favourite
,
:reblog
,
:mention
,
:poll
])
@data_params
||=
params
.
require
(
:data
).
permit
(
alerts:
[
:follow
,
:follow_request
,
:favourite
,
:reblog
,
:mention
,
:poll
,
:status
])
end
end
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
6
7
…
43
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