mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Add notes to /api/v1/accounts/:id/mute (#193)
This commit is contained in:
parent
47ec2eff65
commit
27f8d2c739
@ -26,7 +26,7 @@ class Api::V1::AccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -93,6 +93,8 @@ module AccountInteractions
|
||||
if mute.hide_notifications? != notifications
|
||||
mute.update!(hide_notifications: notifications)
|
||||
end
|
||||
|
||||
mute
|
||||
end
|
||||
|
||||
def mute_conversation!(conversation)
|
||||
|
@ -12,4 +12,6 @@
|
||||
|
||||
class Glitch::Note < ApplicationRecord
|
||||
belongs_to :target, polymorphic: true
|
||||
|
||||
alias_attribute :text, :note
|
||||
end
|
||||
|
@ -2,12 +2,17 @@
|
||||
|
||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking,
|
||||
:muting, :muting_notifications, :requested, :domain_blocking
|
||||
:muting, :muting_notifications, :requested, :domain_blocking,
|
||||
:note
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def note
|
||||
object.respond_to?(:note) ? object.note.text : nil
|
||||
end
|
||||
|
||||
def following
|
||||
instance_options[:relationships].following[object.id] ? true : false
|
||||
end
|
||||
|
@ -1,10 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
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
|
||||
mute = account.mute!(target_account, notifications: notifications)
|
||||
BlockWorker.perform_async(account.id, target_account.id)
|
||||
mute
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user