mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Server side code for Watching First Post Only
This commit is contained in:
@@ -17,6 +17,7 @@ class Category < ActiveRecord::Base
|
||||
belongs_to :latest_post, class_name: "Post"
|
||||
|
||||
has_many :topics
|
||||
has_many :category_users
|
||||
has_many :category_featured_topics
|
||||
has_many :featured_topics, through: :category_featured_topics, source: :topic
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require_dependency 'notification_levels'
|
||||
|
||||
class CategoryUser < ActiveRecord::Base
|
||||
belongs_to :category
|
||||
belongs_to :user
|
||||
@@ -11,11 +13,7 @@ class CategoryUser < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.notification_levels
|
||||
@notification_levels ||= Enum.new(muted: 0,
|
||||
regular: 1,
|
||||
tracking: 2,
|
||||
watching: 3,
|
||||
watching_first_post: 4)
|
||||
NotificationLevels.all
|
||||
end
|
||||
|
||||
def self.watching_levels
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require_dependency 'notification_levels'
|
||||
|
||||
class GroupUser < ActiveRecord::Base
|
||||
belongs_to :group, counter_cache: "user_count"
|
||||
belongs_to :user
|
||||
@@ -10,6 +12,10 @@ class GroupUser < ActiveRecord::Base
|
||||
|
||||
after_save :grant_trust_level
|
||||
|
||||
def self.notification_levels
|
||||
NotificationLevels.all
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_primary_group
|
||||
|
||||
@@ -42,7 +42,8 @@ class Notification < ActiveRecord::Base
|
||||
invited_to_topic: 13,
|
||||
custom: 14,
|
||||
group_mentioned: 15,
|
||||
group_message_summary: 16
|
||||
group_message_summary: 16,
|
||||
watching_first_post: 17
|
||||
)
|
||||
end
|
||||
|
||||
@@ -107,11 +108,6 @@ class Notification < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def text_description
|
||||
link = block_given? ? yield : ""
|
||||
I18n.t("notification_types.#{Notification.types[notification_type]}", data_hash.merge(link: link))
|
||||
end
|
||||
|
||||
def url
|
||||
topic.relative_url(post_number) if topic.present?
|
||||
end
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
require_dependency 'notification_levels'
|
||||
|
||||
class TagUser < ActiveRecord::Base
|
||||
belongs_to :tag
|
||||
belongs_to :user
|
||||
|
||||
def self.notification_levels
|
||||
TopicUser.notification_levels
|
||||
NotificationLevels.all
|
||||
end
|
||||
|
||||
def self.change(user_id, tag_id, level)
|
||||
|
||||
@@ -79,6 +79,7 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
belongs_to :category
|
||||
has_many :category_users, through: :category
|
||||
has_many :posts
|
||||
has_many :ordered_posts, -> { order(post_number: :asc) }, class_name: "Post"
|
||||
has_many :topic_allowed_users
|
||||
@@ -94,6 +95,7 @@ class Topic < ActiveRecord::Base
|
||||
|
||||
has_many :topic_tags, dependent: :destroy
|
||||
has_many :tags, through: :topic_tags
|
||||
has_many :tag_users, through: :tags
|
||||
|
||||
has_one :top_topic
|
||||
belongs_to :user
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
require_dependency 'notification_levels'
|
||||
|
||||
class TopicUser < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :topic
|
||||
@@ -17,10 +19,7 @@ class TopicUser < ActiveRecord::Base
|
||||
|
||||
# Enums
|
||||
def notification_levels
|
||||
@notification_levels ||= Enum.new(muted: 0,
|
||||
regular: 1,
|
||||
tracking: 2,
|
||||
watching: 3)
|
||||
NotificationLevels.topic_levels
|
||||
end
|
||||
|
||||
def notification_reasons
|
||||
|
||||
Reference in New Issue
Block a user