diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-15 03:04:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-15 03:04:13 +0200 |
commit | d0dd9eb5b5d2c0d80a756a6e432b5d502ed0e0fc (patch) | |
tree | 74845d93fd7bf5d85db9489b2f2c23e5989314e0 /app/controllers/api/v1 | |
parent | a588358f41f36b2df1dcc4bb2c3df6c54ed52f88 (diff) |
Feature conversations muting (#3017)
* Add <ostatus:conversation /> tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Conversation muting - prevents notifications that reference a conversation (including replies, favourites, reblogs) from being created. API endpoints /api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute Currently no way to tell when a status/conversation is muted, so the web UI only has a "disable notifications" button, doesn't work as a toggle * Display "Dismiss notifications" on all statuses in notifications column, not just own * Add "muted" as a boolean attribute on statuses JSON For now always false on contained reblogs, since it's only relevant for statuses returned from the notifications endpoint, which are not nested Remove "Disable notifications" from detailed status view, since it's only relevant in the notifications column * Up max class length * Remove pending test for conversation mute * Add tests, clean up * Rename to "mute conversation" and "unmute conversation" * Raise validation error when trying to mute/unmute status without conversation
Diffstat (limited to 'app/controllers/api/v1')
-rw-r--r-- | app/controllers/api/v1/statuses_controller.rb | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 77bdaa494..9312282ed 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true class Api::V1::StatusesController < ApiController - before_action :authorize_if_got_token, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite] - before_action -> { doorkeeper_authorize! :write }, only: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite] - before_action :require_user!, except: [:show, :context, :card, :reblogged_by, :favourited_by] - before_action :set_status, only: [:show, :context, :card, :reblogged_by, :favourited_by] + before_action :authorize_if_got_token, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite, :mute, :unmute] + before_action -> { doorkeeper_authorize! :write }, only: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite, :mute, :unmute] + before_action :require_user!, except: [:show, :context, :card, :reblogged_by, :favourited_by] + before_action :set_status, only: [:show, :context, :card, :reblogged_by, :favourited_by, :mute, :unmute] + before_action :set_conversation, only: [:mute, :unmute] respond_to :json @@ -105,6 +106,22 @@ class Api::V1::StatusesController < ApiController render :show end + def mute + current_account.mute_conversation!(@conversation) + + @mutes_map = { @conversation.id => true } + + render :show + end + + def unmute + current_account.unmute_conversation!(@conversation) + + @mutes_map = { @conversation.id => false } + + render :show + end + private def set_status @@ -112,6 +129,11 @@ class Api::V1::StatusesController < ApiController raise ActiveRecord::RecordNotFound unless @status.permitted?(current_account) end + def set_conversation + @conversation = @status.conversation + raise Mastodon::ValidationError if @conversation.nil? + end + def status_params params.permit(:status, :in_reply_to_id, :sensitive, :spoiler_text, :visibility, media_ids: []) end |