logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

account_moderation_notes_controller.rb (1271B)


  1. # frozen_string_literal: true
  2. module Admin
  3. class AccountModerationNotesController < BaseController
  4. before_action :set_account_moderation_note, only: [:destroy]
  5. def create
  6. authorize AccountModerationNote, :create?
  7. @account_moderation_note = current_account.account_moderation_notes.new(resource_params)
  8. if @account_moderation_note.save
  9. redirect_to admin_account_path(@account_moderation_note.target_account_id), notice: I18n.t('admin.account_moderation_notes.created_msg')
  10. else
  11. @account = @account_moderation_note.target_account
  12. @moderation_notes = @account.targeted_moderation_notes.latest
  13. render template: 'admin/accounts/show'
  14. end
  15. end
  16. def destroy
  17. authorize @account_moderation_note, :destroy?
  18. @account_moderation_note.destroy!
  19. redirect_to admin_account_path(@account_moderation_note.target_account_id), notice: I18n.t('admin.account_moderation_notes.destroyed_msg')
  20. end
  21. private
  22. def resource_params
  23. params.require(:account_moderation_note).permit(
  24. :content,
  25. :target_account_id
  26. )
  27. end
  28. def set_account_moderation_note
  29. @account_moderation_note = AccountModerationNote.find(params[:id])
  30. end
  31. end
  32. end