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