mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 10:56:15 +08:00
don't treat notify user as a flag
This commit is contained in:
parent
034513f0fa
commit
2bdb53261b
|
@ -43,7 +43,12 @@ Discourse.ActionSummary = Discourse.Model.extend({
|
||||||
this.set('acted', true);
|
this.set('acted', true);
|
||||||
this.set('count', this.get('count') + 1);
|
this.set('count', this.get('count') + 1);
|
||||||
this.set('can_act', false);
|
this.set('can_act', false);
|
||||||
this.set('can_undo', action !== 'notify_moderators' && action !== 'notify_user');
|
this.set('can_undo', true);
|
||||||
|
|
||||||
|
if(action === 'notify_moderators' || action=='notify_user') {
|
||||||
|
this.set('can_undo',false);
|
||||||
|
this.set('can_clear_flags',false);
|
||||||
|
}
|
||||||
|
|
||||||
// Add ourselves to the users who liked it if present
|
// Add ourselves to the users who liked it if present
|
||||||
if (this.present('users')) {
|
if (this.present('users')) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ join (
|
||||||
limit 100
|
limit 100
|
||||||
"
|
"
|
||||||
|
|
||||||
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values
|
sql.where2 "post_action_type_id in (:flag_types)", flag_types: PostActionType.notify_flag_types.values
|
||||||
|
|
||||||
|
|
||||||
# it may make sense to add a view that shows flags on deleted posts,
|
# it may make sense to add a view that shows flags on deleted posts,
|
||||||
|
@ -62,7 +62,7 @@ limit 100
|
||||||
from post_actions a
|
from post_actions a
|
||||||
/*where*/
|
/*where*/
|
||||||
"
|
"
|
||||||
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.flag_types.values)
|
sql.where("post_action_type_id in (:flag_types)", flag_types: PostActionType.notify_flag_types.values)
|
||||||
sql.where("post_id in (:posts)", posts: posts.map{|p| p["id"].to_i})
|
sql.where("post_id in (:posts)", posts: posts.map{|p| p["id"].to_i})
|
||||||
|
|
||||||
if params[:filter] == 'old'
|
if params[:filter] == 'old'
|
||||||
|
|
|
@ -20,7 +20,7 @@ class PostAction < ActiveRecord::Base
|
||||||
|
|
||||||
def self.update_flagged_posts_count
|
def self.update_flagged_posts_count
|
||||||
posts_flagged_count = PostAction.joins(post: :topic)
|
posts_flagged_count = PostAction.joins(post: :topic)
|
||||||
.where('post_actions.post_action_type_id' => PostActionType.flag_types.values,
|
.where('post_actions.post_action_type_id' => PostActionType.notify_flag_types.values,
|
||||||
'posts.deleted_at' => nil,
|
'posts.deleted_at' => nil,
|
||||||
'topics.deleted_at' => nil).count('DISTINCT posts.id')
|
'topics.deleted_at' => nil).count('DISTINCT posts.id')
|
||||||
|
|
||||||
|
@ -74,23 +74,23 @@ class PostAction < ActiveRecord::Base
|
||||||
def self.act(user, post, post_action_type_id, message = nil)
|
def self.act(user, post, post_action_type_id, message = nil)
|
||||||
begin
|
begin
|
||||||
title, target_usernames,body = nil
|
title, target_usernames,body = nil
|
||||||
|
|
||||||
if message
|
if message
|
||||||
[:notify_moderators, :notify_user].each do |k|
|
[:notify_moderators, :notify_user].each do |k|
|
||||||
if post_action_type_id == PostActionType.types[k]
|
if post_action_type_id == PostActionType.types[k]
|
||||||
target_usernames = k == :notify_moderators ? target_moderators(user) : post.user.username
|
target_usernames = k == :notify_moderators ? target_moderators(user) : post.user.username
|
||||||
title = I18n.t("post_action_types.#{k}.email_title",
|
title = I18n.t("post_action_types.#{k}.email_title",
|
||||||
title: post.topic.title)
|
title: post.topic.title)
|
||||||
body = I18n.t("post_action_types.#{k}.email_body",
|
body = I18n.t("post_action_types.#{k}.email_body",
|
||||||
message: message,
|
message: message,
|
||||||
link: "#{Discourse.base_url}#{post.url}")
|
link: "#{Discourse.base_url}#{post.url}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if target_usernames.present?
|
if target_usernames.present?
|
||||||
PostCreator.new(user,
|
PostCreator.new(user,
|
||||||
target_usernames: target_usernames,
|
target_usernames: target_usernames,
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
title: title,
|
title: title,
|
||||||
raw: body
|
raw: body
|
||||||
|
@ -169,11 +169,11 @@ class PostAction < ActiveRecord::Base
|
||||||
Topic.update_all ["#{column} = #{column} + ?", delta], id: post.topic_id
|
Topic.update_all ["#{column} = #{column} + ?", delta], id: post.topic_id
|
||||||
|
|
||||||
|
|
||||||
if PostActionType.flag_types.values.include?(post_action_type_id)
|
if PostActionType.notify_flag_types.values.include?(post_action_type_id)
|
||||||
PostAction.update_flagged_posts_count
|
PostAction.update_flagged_posts_count
|
||||||
end
|
end
|
||||||
|
|
||||||
if SiteSetting.flags_required_to_hide_post > 0
|
if PostActionType.auto_action_flag_types.include?(post_action_type) && SiteSetting.flags_required_to_hide_post > 0
|
||||||
# automatic hiding of posts
|
# automatic hiding of posts
|
||||||
flag_counts = exec_sql("SELECT SUM(CASE WHEN deleted_at IS NULL THEN 1 ELSE 0 END) AS new_flags,
|
flag_counts = exec_sql("SELECT SUM(CASE WHEN deleted_at IS NULL THEN 1 ELSE 0 END) AS new_flags,
|
||||||
SUM(CASE WHEN deleted_at IS NOT NULL THEN 1 ELSE 0 END) AS old_flags
|
SUM(CASE WHEN deleted_at IS NOT NULL THEN 1 ELSE 0 END) AS old_flags
|
||||||
|
@ -197,7 +197,7 @@ class PostAction < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def self.target_moderators(me)
|
def self.target_moderators(me)
|
||||||
User
|
User
|
||||||
|
|
|
@ -21,6 +21,11 @@ class PostActionType < ActiveRecord::Base
|
||||||
@flag_types ||= types.only(:off_topic, :spam, :inappropriate, :notify_user, :notify_moderators)
|
@flag_types ||= types.only(:off_topic, :spam, :inappropriate, :notify_user, :notify_moderators)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# flags resulting in mod notifications
|
||||||
|
def notify_flag_types
|
||||||
|
@notify_flag_types ||= types.only(:off_topic, :spam, :inappropriate, :notify_moderators)
|
||||||
|
end
|
||||||
|
|
||||||
def is_flag?(sym)
|
def is_flag?(sym)
|
||||||
flag_types.valid?(sym)
|
flag_types.valid?(sym)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user