FIX: Support for long suspension emails
This commit is contained in:
parent
8496191f0b
commit
0a9daba627
|
@ -2,5 +2,5 @@
|
|||
<pre>{{model.details}}</pre>
|
||||
{{/d-modal-body}}
|
||||
<div class="modal-footer">
|
||||
<button class='btn btn-primary' {{action "closeModal"}}>{{i18n 'close'}}</button>
|
||||
{{d-button action=(action "closeModal") label="close"}}
|
||||
</div>
|
||||
|
|
|
@ -1374,6 +1374,12 @@ table.api-keys {
|
|||
}
|
||||
|
||||
.log-details-modal {
|
||||
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
max-height: 250px;
|
||||
}
|
||||
|
||||
.modal-tab {
|
||||
width: 95%;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
user_history = StaffActionLogger.new(current_user).log_user_suspend(
|
||||
@user,
|
||||
params[:reason],
|
||||
context: message,
|
||||
message: message,
|
||||
post_id: params[:post_id]
|
||||
)
|
||||
end
|
||||
|
@ -282,7 +282,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
current_user,
|
||||
silenced_till: params[:silenced_till],
|
||||
reason: params[:reason],
|
||||
context: message,
|
||||
message_body: message,
|
||||
keep_posts: true
|
||||
)
|
||||
if silencer.silence && message.present?
|
||||
|
|
|
@ -169,10 +169,14 @@ class StaffActionLogger
|
|||
|
||||
def log_user_suspend(user, reason, opts = {})
|
||||
raise Discourse::InvalidParameters.new(:user) unless user
|
||||
|
||||
details = (reason || '').dup
|
||||
details << "\n\n#{opts[:message]}" if opts[:message].present?
|
||||
|
||||
args = params(opts).merge(
|
||||
action: UserHistory.actions[:suspend_user],
|
||||
target_user_id: user.id,
|
||||
details: reason
|
||||
details: details
|
||||
)
|
||||
args[:post_id] = opts[:post_id] if opts[:post_id]
|
||||
UserHistory.create(args)
|
||||
|
@ -275,6 +279,7 @@ class StaffActionLogger
|
|||
|
||||
def log_silence_user(user, opts = {})
|
||||
raise Discourse::InvalidParameters.new(:user) unless user
|
||||
|
||||
UserHistory.create(
|
||||
params(opts).merge(
|
||||
action: UserHistory.actions[:silence_user],
|
||||
|
|
|
@ -21,18 +21,17 @@ class UserSilencer
|
|||
if @user.save
|
||||
message_type = @opts[:message] || :silenced_by_staff
|
||||
|
||||
if @opts[:context].present?
|
||||
context = @opts[:context]
|
||||
else
|
||||
context = "#{message_type}: '#{post.topic&.title rescue ''}' #{@opts[:reason]}"
|
||||
SystemMessage.create(@user, message_type)
|
||||
end
|
||||
details = (@opts[:reason] || '').dup
|
||||
details << "\n\n#{@opts[:message_body]}" if @opts[:message_body].present?
|
||||
|
||||
context = "#{message_type}: '#{post.topic&.title rescue ''}' #{@opts[:reason]}"
|
||||
SystemMessage.create(@user, message_type)
|
||||
|
||||
if @by_user
|
||||
@user_history = StaffActionLogger.new(@by_user).log_silence_user(
|
||||
@user,
|
||||
context: context,
|
||||
details: @opts[:reason]
|
||||
details: details
|
||||
)
|
||||
end
|
||||
return true
|
||||
|
|
|
@ -192,7 +192,7 @@ describe Admin::UsersController do
|
|||
log = UserHistory.where(target_user_id: user.id).order('id desc').first
|
||||
expect(log).to be_present
|
||||
expect(log.details).to match(/short reason/)
|
||||
expect(log.context).to match(/long reason/)
|
||||
expect(log.details).to match(/long reason/)
|
||||
end
|
||||
|
||||
it "also revoke any api keys" do
|
||||
|
@ -610,6 +610,7 @@ describe Admin::UsersController do
|
|||
end
|
||||
|
||||
it "will send a message if provided" do
|
||||
Jobs.stubs(:enqueue)
|
||||
Jobs.expects(:enqueue).with(
|
||||
:critical_user_email,
|
||||
has_entries(
|
||||
|
|
Loading…
Reference in New Issue