mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
UX: Use smaller messages for moderator actions.
This commit is contained in:
parent
326b2812e4
commit
bb93a345eb
25 changed files with 171 additions and 60 deletions
|
@ -0,0 +1,36 @@
|
||||||
|
const icons = {
|
||||||
|
'closed.enabled': 'lock',
|
||||||
|
'closed.disabled': 'unlock-alt',
|
||||||
|
'archived.enabled': 'folder',
|
||||||
|
'archived.disabled': 'folder-open',
|
||||||
|
'pinned.enabled': 'thumb-tack',
|
||||||
|
'pinned.disabled': 'thumb-tack',
|
||||||
|
'visible.enabled': 'eye',
|
||||||
|
'visible.disabled': 'eye-slash'
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
layoutName: 'components/small-action', // needed because `time-gap` inherits from this
|
||||||
|
classNames: ['small-action'],
|
||||||
|
|
||||||
|
description: function() {
|
||||||
|
const actionCode = this.get('actionCode');
|
||||||
|
if (actionCode) {
|
||||||
|
const dt = new Date(this.get('post.created_at'));
|
||||||
|
const when = Discourse.Formatter.relativeAge(dt, {format: 'medium-with-ago'});
|
||||||
|
const result = I18n.t(`action_codes.${actionCode}`, {when});
|
||||||
|
return result + (this.get('post.cooked') || '');
|
||||||
|
}
|
||||||
|
}.property('actionCode', 'post.created_at', 'post.cooked'),
|
||||||
|
|
||||||
|
icon: function() {
|
||||||
|
return icons[this.get('actionCode')] || 'exclamation';
|
||||||
|
}.property('actionCode'),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
edit: function() {
|
||||||
|
this.sendAction('editPost', this.get('post'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -1,22 +1,19 @@
|
||||||
export default Ember.Component.extend({
|
import SmallActionComponent from 'discourse/components/small-action';
|
||||||
classNameBindings: [':time-gap'],
|
|
||||||
|
|
||||||
render(buffer) {
|
export default SmallActionComponent.extend({
|
||||||
const gapDays = this.get('gapDays');
|
classNames: ['time-gap'],
|
||||||
|
icon: 'clock-o',
|
||||||
|
|
||||||
buffer.push("<div class='topic-avatar'><i class='fa fa-clock-o'></i></div>");
|
description: function() {
|
||||||
|
const gapDays = this.get('daysAgo');
|
||||||
let timeGapWords;
|
|
||||||
if (gapDays < 30) {
|
if (gapDays < 30) {
|
||||||
timeGapWords = I18n.t('dates.later.x_days', {count: gapDays});
|
return I18n.t('dates.later.x_days', {count: gapDays});
|
||||||
} else if (gapDays < 365) {
|
} else if (gapDays < 365) {
|
||||||
const gapMonths = Math.floor(gapDays / 30);
|
const gapMonths = Math.floor(gapDays / 30);
|
||||||
timeGapWords = I18n.t('dates.later.x_months', {count: gapMonths});
|
return I18n.t('dates.later.x_months', {count: gapMonths});
|
||||||
} else {
|
} else {
|
||||||
const gapYears = Math.floor(gapDays / 365);
|
const gapYears = Math.floor(gapDays / 365);
|
||||||
timeGapWords = I18n.t('dates.later.x_years', {count: gapYears});
|
return I18n.t('dates.later.x_years', {count: gapYears});
|
||||||
}
|
}
|
||||||
|
}.property(),
|
||||||
buffer.push("<div class='time-gap-words'>" + timeGapWords + "</div>");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -592,6 +592,7 @@ export default ObjectController.extend(SelectedPostsCount, BufferedContent, {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
this.messageBus.subscribe("/topic/" + this.get('model.id'), function(data) {
|
this.messageBus.subscribe("/topic/" + this.get('model.id'), function(data) {
|
||||||
|
console.log(data);
|
||||||
const topic = self.get('model');
|
const topic = self.get('model');
|
||||||
|
|
||||||
if (data.notification_level_change) {
|
if (data.notification_level_change) {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<div class='topic-avatar'>{{fa-icon icon}}</div>
|
||||||
|
<div class='small-action-desc'>
|
||||||
|
{{#if post}}
|
||||||
|
<button {{action "edit"}} title="{{i18n "post.controls.edit"}}">{{fa-icon "pencil"}}</button>
|
||||||
|
<a href={{post.usernameUrl}} data-user-card={{post.username}}>
|
||||||
|
{{avatar post imageSize="small"}}
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
|
<p>{{{description}}}</p>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
{{post-gap post=this postStream=controller.model.postStream before="true"}}
|
||||||
|
{{small-action actionCode=action_code post=this daysAgo=view.daysAgo editPost="editPost"}}
|
||||||
|
{{post-gap post=this postStream=controller.model.postStream before="false"}}
|
|
@ -1,7 +1,7 @@
|
||||||
{{post-gap post=this postStream=controller.model.postStream before="true"}}
|
{{post-gap post=this postStream=controller.model.postStream before="true"}}
|
||||||
|
|
||||||
{{#if hasTimeGap}}
|
{{#if hasTimeGap}}
|
||||||
{{time-gap gapDays=daysSincePrevious}}
|
{{time-gap daysAgo=daysSincePrevious}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
|
|
|
@ -2,7 +2,6 @@ const DAY = 60 * 50 * 1000;
|
||||||
|
|
||||||
const PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
const PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
classNames: ['topic-post', 'clearfix'],
|
classNames: ['topic-post', 'clearfix'],
|
||||||
templateName: 'post',
|
|
||||||
classNameBindings: ['needsModeratorClass:moderator:regular',
|
classNameBindings: ['needsModeratorClass:moderator:regular',
|
||||||
'selected',
|
'selected',
|
||||||
'post.hidden:post-hidden',
|
'post.hidden:post-hidden',
|
||||||
|
@ -13,6 +12,10 @@ const PostView = Discourse.GroupedView.extend(Ember.Evented, {
|
||||||
|
|
||||||
post: Ember.computed.alias('content'),
|
post: Ember.computed.alias('content'),
|
||||||
|
|
||||||
|
templateName: function() {
|
||||||
|
return (this.get('post.post_type') === 3) ? 'post-small-action' : 'post';
|
||||||
|
}.property('post.post_type'),
|
||||||
|
|
||||||
historyHeat: function() {
|
historyHeat: function() {
|
||||||
const updatedAt = this.get('post.updated_at');
|
const updatedAt = this.get('post.updated_at');
|
||||||
if (!updatedAt) { return; }
|
if (!updatedAt) { return; }
|
||||||
|
|
|
@ -726,35 +726,56 @@ $topic-avatar-width: 45px;
|
||||||
width: calc(#{$topic-avatar-width} + #{$topic-body-width} + 2 * #{$topic-body-width-padding});
|
width: calc(#{$topic-avatar-width} + #{$topic-body-width} + 2 * #{$topic-body-width-padding});
|
||||||
}
|
}
|
||||||
|
|
||||||
.time-gap {
|
.small-action {
|
||||||
width: 755px;
|
width: 755px;
|
||||||
border-top: 1px solid dark-light-diff($primary, $secondary, 90%, -60%);
|
border-top: 1px solid dark-light-diff($primary, $secondary, 90%, -60%);
|
||||||
|
|
||||||
.topic-avatar {
|
.topic-avatar {
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
border-top: none;
|
border-top: none;
|
||||||
|
float: left;
|
||||||
|
i {
|
||||||
|
font-size: 35px;
|
||||||
|
width: 45px;
|
||||||
|
text-align: center;
|
||||||
|
color: lighten($primary, 75%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.time-gap .topic-avatar i {
|
.small-action-desc {
|
||||||
font-size: 35px;
|
display: inline-block;
|
||||||
width: 45px;
|
padding: 0.5em 1em;
|
||||||
text-align: center;
|
margin-top: 5px;
|
||||||
color: lighten($primary, 75%);
|
text-transform: uppercase;
|
||||||
}
|
font-weight: bold;
|
||||||
.time-gap-words {
|
font-size: 0.9em;
|
||||||
display: inline-block;
|
color: lighten($primary, 60%);
|
||||||
padding: 0.5em 1em;
|
width: 680px;
|
||||||
margin-top: 9px;
|
|
||||||
text-transform: uppercase;
|
.avatar {
|
||||||
font-weight: bold;
|
margin-right: 0.8em;
|
||||||
font-size: 0.9em;
|
float: left;
|
||||||
color: lighten($primary, 60%);
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.posts-wrapper {
|
.posts-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
-webkit-font-smoothing: subpixel-antialiased;
|
-webkit-font-smoothing: subpixel-antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown {
|
.dropdown {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -59,7 +59,7 @@ class DirectoryItem < ActiveRecord::Base
|
||||||
AND COALESCE(t.visible, true)
|
AND COALESCE(t.visible, true)
|
||||||
AND p.deleted_at IS NULL
|
AND p.deleted_at IS NULL
|
||||||
AND (NOT (COALESCE(p.hidden, false)))
|
AND (NOT (COALESCE(p.hidden, false)))
|
||||||
AND COALESCE(p.post_type, :regular_post_type) != :moderator_action
|
AND COALESCE(p.post_type, :regular_post_type) = :regular_post_type
|
||||||
AND u.id > 0
|
AND u.id > 0
|
||||||
GROUP BY u.id",
|
GROUP BY u.id",
|
||||||
period_type: period_types[period_type],
|
period_type: period_types[period_type],
|
||||||
|
@ -68,8 +68,7 @@ class DirectoryItem < ActiveRecord::Base
|
||||||
was_liked_type: UserAction::WAS_LIKED,
|
was_liked_type: UserAction::WAS_LIKED,
|
||||||
new_topic_type: UserAction::NEW_TOPIC,
|
new_topic_type: UserAction::NEW_TOPIC,
|
||||||
reply_type: UserAction::REPLY,
|
reply_type: UserAction::REPLY,
|
||||||
regular_post_type: Post.types[:regular],
|
regular_post_type: Post.types[:regular]
|
||||||
moderator_action: Post.types[:moderator_action]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Post < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.types
|
def self.types
|
||||||
@types ||= Enum.new(:regular, :moderator_action)
|
@types ||= Enum.new(:regular, :moderator_action, :small_action)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.cook_methods
|
def self.cook_methods
|
||||||
|
@ -99,10 +99,10 @@ class Post < ActiveRecord::Base
|
||||||
# consistency checks should fix, but message
|
# consistency checks should fix, but message
|
||||||
# is safe to skip
|
# is safe to skip
|
||||||
MessageBus.publish("/topic/#{topic_id}", {
|
MessageBus.publish("/topic/#{topic_id}", {
|
||||||
id: id,
|
id: id,
|
||||||
post_number: post_number,
|
post_number: post_number,
|
||||||
updated_at: Time.now,
|
updated_at: Time.now,
|
||||||
type: type
|
type: type
|
||||||
}, group_ids: topic.secure_group_ids) if topic
|
}, group_ids: topic.secure_group_ids) if topic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def staff_already_replied?(topic)
|
def staff_already_replied?(topic)
|
||||||
topic.posts.where("user_id IN (SELECT id FROM users WHERE moderator OR admin) OR post_type = :post_type", post_type: Post.types[:moderator_action]).exists?
|
topic.posts.where("user_id IN (SELECT id FROM users WHERE moderator OR admin) OR (post_type != :regular_post_type)", regular_post_type: Post.types[:regular]).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_message_for_post_action(user, post, post_action_type_id, opts)
|
def self.create_message_for_post_action(user, post, post_action_type_id, opts)
|
||||||
|
|
|
@ -489,15 +489,18 @@ class Topic < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_moderator_post(user, text, opts={})
|
def add_moderator_post(user, text, opts=nil)
|
||||||
|
opts ||= {}
|
||||||
new_post = nil
|
new_post = nil
|
||||||
Topic.transaction do
|
Topic.transaction do
|
||||||
creator = PostCreator.new(user,
|
creator = PostCreator.new(user,
|
||||||
raw: text,
|
raw: text,
|
||||||
post_type: Post.types[:moderator_action],
|
post_type: opts[:post_type] || Post.types[:moderator_action],
|
||||||
|
action_code: opts[:action_code],
|
||||||
no_bump: opts[:bump].blank?,
|
no_bump: opts[:bump].blank?,
|
||||||
skip_notifications: opts[:skip_notifications],
|
skip_notifications: opts[:skip_notifications],
|
||||||
topic_id: self.id)
|
topic_id: self.id,
|
||||||
|
skip_validations: true)
|
||||||
new_post = creator.create
|
new_post = creator.create
|
||||||
increment!(:moderator_posts_count)
|
increment!(:moderator_posts_count)
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,8 +49,6 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
|
||||||
locale_key = status.locale_key
|
locale_key = status.locale_key
|
||||||
locale_key << "_lastpost" if topic.auto_close_based_on_last_post
|
locale_key << "_lastpost" if topic.auto_close_based_on_last_post
|
||||||
message_for_autoclosed(locale_key)
|
message_for_autoclosed(locale_key)
|
||||||
else
|
|
||||||
I18n.t(status.locale_key)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,7 +67,9 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def options_for(status)
|
def options_for(status)
|
||||||
{ bump: status.reopening_topic? }
|
{ bump: status.reopening_topic?,
|
||||||
|
post_type: Post.types[:small_action],
|
||||||
|
action_code: status.action_code }
|
||||||
end
|
end
|
||||||
|
|
||||||
Status = Struct.new(:name, :enabled) do
|
Status = Struct.new(:name, :enabled) do
|
||||||
|
@ -85,8 +85,12 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
|
||||||
!enabled?
|
!enabled?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def action_code
|
||||||
|
"#{name}.#{enabled? ? 'enabled' : 'disabled'}"
|
||||||
|
end
|
||||||
|
|
||||||
def locale_key
|
def locale_key
|
||||||
"topic_statuses.#{name}_#{enabled? ? 'enabled' : 'disabled'}"
|
"topic_statuses.#{action_code.gsub('.', '_')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def reopening_topic?
|
def reopening_topic?
|
||||||
|
|
|
@ -46,7 +46,7 @@ class AdminPostSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator_action
|
def moderator_action
|
||||||
object.post_type == Post.types[:moderator_action]
|
object.post_type == Post.types[:moderator_action] || object.post_type == Post.types[:small_action]
|
||||||
end
|
end
|
||||||
|
|
||||||
def deleted_by
|
def deleted_by
|
||||||
|
|
|
@ -57,7 +57,8 @@ class PostSerializer < BasicPostSerializer
|
||||||
:wiki,
|
:wiki,
|
||||||
:user_custom_fields,
|
:user_custom_fields,
|
||||||
:static_doc,
|
:static_doc,
|
||||||
:via_email
|
:via_email,
|
||||||
|
:action_code
|
||||||
|
|
||||||
def initialize(object, opts)
|
def initialize(object, opts)
|
||||||
super(object, opts)
|
super(object, opts)
|
||||||
|
@ -281,6 +282,10 @@ class PostSerializer < BasicPostSerializer
|
||||||
scope.is_staff? ? object.version : object.public_version
|
scope.is_staff? ? object.version : object.public_version
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_action_code?
|
||||||
|
object.action_code.present?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def post_actions
|
def post_actions
|
||||||
|
|
|
@ -68,7 +68,7 @@ class UserActionSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator_action
|
def moderator_action
|
||||||
object.post_type == Post.types[:moderator_action]
|
object.post_type == Post.types[:moderator_action] || object.post_type == Post.types[:small_action]
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_reply_to_post_number?
|
def include_reply_to_post_number?
|
||||||
|
|
|
@ -24,7 +24,7 @@ class PostAlerter
|
||||||
end
|
end
|
||||||
create_notification(user, Notification.types[:private_message], post)
|
create_notification(user, Notification.types[:private_message], post)
|
||||||
end
|
end
|
||||||
elsif post.post_type != Post.types[:moderator_action]
|
elsif post.post_type == Post.types[:regular]
|
||||||
# If it's not a private message and it's not an automatic post caused by a moderator action, notify the users
|
# If it's not a private message and it's not an automatic post caused by a moderator action, notify the users
|
||||||
notify_post_users(post)
|
notify_post_users(post)
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,6 +119,20 @@ en:
|
||||||
google+: 'share this link on Google+'
|
google+: 'share this link on Google+'
|
||||||
email: 'send this link in an email'
|
email: 'send this link in an email'
|
||||||
|
|
||||||
|
action_codes:
|
||||||
|
closed:
|
||||||
|
enabled: 'closed this topic %{when}'
|
||||||
|
disabled: 'opened this topic %{when}'
|
||||||
|
archived:
|
||||||
|
enabled: 'archived this topic %{when}'
|
||||||
|
disabled: 'unarchived this topic %{when}'
|
||||||
|
pinned:
|
||||||
|
enabled: 'pinned this topic %{when}'
|
||||||
|
disabled: 'unpinned this topic %{when}'
|
||||||
|
visible:
|
||||||
|
enabled: 'unlisted this topic %{when}'
|
||||||
|
disabled: 'listed this topic %{when}'
|
||||||
|
|
||||||
topic_admin_menu: "topic admin actions"
|
topic_admin_menu: "topic admin actions"
|
||||||
|
|
||||||
emails_are_disabled: "All outgoing email has been globally disabled by an administrator. No email notifications of any kind will be sent."
|
emails_are_disabled: "All outgoing email has been globally disabled by an administrator. No email notifications of any kind will be sent."
|
||||||
|
|
5
db/migrate/20150724182342_add_action_code_to_post.rb
Normal file
5
db/migrate/20150724182342_add_action_code_to_post.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddActionCodeToPost < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :posts, :action_code, :string, null: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -139,7 +139,7 @@ module Tilt
|
||||||
|
|
||||||
def generate_source(scope)
|
def generate_source(scope)
|
||||||
js_source = ::JSON.generate(data, quirks_mode: true)
|
js_source = ::JSON.generate(data, quirks_mode: true)
|
||||||
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring']})['code']"
|
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring', 'es6.templateLiterals']})['code']"
|
||||||
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
|
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ class PostCreator
|
||||||
# :raw_email - Imported from an email
|
# :raw_email - Imported from an email
|
||||||
# via_email - Mark this post as arriving via email
|
# via_email - Mark this post as arriving via email
|
||||||
# raw_email - Full text of arriving email (to store)
|
# raw_email - Full text of arriving email (to store)
|
||||||
|
# action_code - Describes a small_action post (optional)
|
||||||
#
|
#
|
||||||
# When replying to a topic:
|
# When replying to a topic:
|
||||||
# topic_id - topic we're replying to
|
# topic_id - topic we're replying to
|
||||||
|
@ -255,7 +256,7 @@ class PostCreator
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_post
|
def setup_post
|
||||||
@opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw]).gsub(/\s+\z/, "")
|
@opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw] || '').gsub(/\s+\z/, "")
|
||||||
|
|
||||||
post = Post.new(raw: @opts[:raw],
|
post = Post.new(raw: @opts[:raw],
|
||||||
topic_id: @topic.try(:id),
|
topic_id: @topic.try(:id),
|
||||||
|
@ -263,7 +264,7 @@ class PostCreator
|
||||||
reply_to_post_number: @opts[:reply_to_post_number])
|
reply_to_post_number: @opts[:reply_to_post_number])
|
||||||
|
|
||||||
# Attributes we pass through to the post instance if present
|
# Attributes we pass through to the post instance if present
|
||||||
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email, :raw_email].each do |a|
|
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email, :raw_email, :action_code].each do |a|
|
||||||
post.send("#{a}=", @opts[a]) if @opts[a].present?
|
post.send("#{a}=", @opts[a]) if @opts[a].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ class PostJobsEnqueuer
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_after_create?
|
def skip_after_create?
|
||||||
@opts[:import_mode] || @topic.private_message? || @post.post_type == Post.types[:moderator_action]
|
@opts[:import_mode] ||
|
||||||
|
@topic.private_message? ||
|
||||||
|
@post.post_type == Post.types[:moderator_action] ||
|
||||||
|
@post.post_type == Post.types[:small_action]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -379,7 +379,7 @@ class TopicView
|
||||||
end
|
end
|
||||||
|
|
||||||
if @best.present?
|
if @best.present?
|
||||||
@filtered_posts = @filtered_posts.where('posts.post_type <> ?', Post.types[:moderator_action])
|
@filtered_posts = @filtered_posts.where('posts.post_type = ?', Post.types[:regular])
|
||||||
@contains_gaps = true
|
@contains_gaps = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,7 @@ class ImportScripts::Base
|
||||||
|
|
||||||
def update_bumped_at
|
def update_bumped_at
|
||||||
puts "", "updating bumped_at on topics"
|
puts "", "updating bumped_at on topics"
|
||||||
Post.exec_sql("update topics t set bumped_at = COALESCE((select max(created_at) from posts where topic_id = t.id and post_type != #{Post.types[:moderator_action]}), bumped_at)")
|
Post.exec_sql("update topics t set bumped_at = COALESCE((select max(created_at) from posts where topic_id = t.id and post_type = #{Post.types[:regular]}), bumped_at)")
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_last_posted_at
|
def update_last_posted_at
|
||||||
|
|
|
@ -30,7 +30,10 @@ describe TopicStatusUpdate do
|
||||||
|
|
||||||
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
||||||
|
|
||||||
expect(topic.posts.last.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_minutes", count: 0))
|
last_post = topic.posts.last
|
||||||
|
expect(last_post.post_type).to eq(Post.types[:small_action])
|
||||||
|
expect(last_post.action_code).to eq('autoclosed.enabled')
|
||||||
|
expect(last_post.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_minutes", count: 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds an autoclosed message based on last post" do
|
it "adds an autoclosed message based on last post" do
|
||||||
|
@ -39,7 +42,10 @@ describe TopicStatusUpdate do
|
||||||
|
|
||||||
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
TopicStatusUpdate.new(topic, admin).update!("autoclosed", true)
|
||||||
|
|
||||||
expect(topic.posts.last.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_lastpost_minutes", count: 0))
|
last_post = topic.posts.last
|
||||||
|
expect(last_post.post_type).to eq(Post.types[:small_action])
|
||||||
|
expect(last_post.action_code).to eq('autoclosed.enabled')
|
||||||
|
expect(last_post.raw).to eq(I18n.t("topic_statuses.autoclosed_enabled_lastpost_minutes", count: 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue