mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Add notes to /api/v1/accounts/:id/mute (#193)
This commit is contained in:
@@ -26,7 +26,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mute
|
def mute
|
||||||
MuteService.new.call(current_user.account, @account, notifications: params[:notifications])
|
MuteService.new.call(current_user.account, @account, notifications: params[:notifications], note: params[:note])
|
||||||
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ module AccountInteractions
|
|||||||
if mute.hide_notifications? != notifications
|
if mute.hide_notifications? != notifications
|
||||||
mute.update!(hide_notifications: notifications)
|
mute.update!(hide_notifications: notifications)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mute
|
||||||
end
|
end
|
||||||
|
|
||||||
def mute_conversation!(conversation)
|
def mute_conversation!(conversation)
|
||||||
|
|||||||
@@ -12,4 +12,6 @@
|
|||||||
|
|
||||||
class Glitch::Note < ApplicationRecord
|
class Glitch::Note < ApplicationRecord
|
||||||
belongs_to :target, polymorphic: true
|
belongs_to :target, polymorphic: true
|
||||||
|
|
||||||
|
alias_attribute :text, :note
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking,
|
attributes :id, :following, :showing_reblogs, :followed_by, :blocking,
|
||||||
:muting, :muting_notifications, :requested, :domain_blocking
|
:muting, :muting_notifications, :requested, :domain_blocking,
|
||||||
|
:note
|
||||||
|
|
||||||
def id
|
def id
|
||||||
object.id.to_s
|
object.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def note
|
||||||
|
object.respond_to?(:note) ? object.note.text : nil
|
||||||
|
end
|
||||||
|
|
||||||
def following
|
def following
|
||||||
instance_options[:relationships].following[object.id] ? true : false
|
instance_options[:relationships].following[object.id] ? true : false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MuteService < BaseService
|
class MuteService < BaseService
|
||||||
def call(account, target_account, notifications: nil)
|
def call(account, target_account, notifications: nil, note: nil)
|
||||||
return if account.id == target_account.id
|
return if account.id == target_account.id
|
||||||
mute = account.mute!(target_account, notifications: notifications)
|
|
||||||
BlockWorker.perform_async(account.id, target_account.id)
|
ActiveRecord::Base.transaction do
|
||||||
mute
|
mute = account.mute!(target_account, notifications: notifications)
|
||||||
|
mute.create_note!(note: note) if note
|
||||||
|
BlockWorker.perform_async(account.id, target_account.id)
|
||||||
|
mute
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user