thredded 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/commands/thredded/at_notification_extractor.rb +1 -0
- data/app/commands/thredded/autofollow_users.rb +1 -0
- data/app/commands/thredded/create_messageboard.rb +1 -0
- data/app/commands/thredded/mark_all_read.rb +1 -0
- data/app/commands/thredded/moderate_post.rb +1 -0
- data/app/commands/thredded/notify_following_users.rb +1 -0
- data/app/commands/thredded/notify_private_topic_users.rb +1 -0
- data/app/controllers/concerns/thredded/new_post_params.rb +1 -0
- data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -0
- data/app/controllers/concerns/thredded/new_private_topic_params.rb +1 -0
- data/app/controllers/concerns/thredded/new_topic_params.rb +1 -0
- data/app/controllers/concerns/thredded/render_preview.rb +1 -0
- data/app/controllers/thredded/application_controller.rb +1 -0
- data/app/controllers/thredded/autocomplete_users_controller.rb +1 -0
- data/app/controllers/thredded/messageboards_controller.rb +4 -3
- data/app/controllers/thredded/moderation_controller.rb +1 -0
- data/app/controllers/thredded/post_permalinks_controller.rb +1 -0
- data/app/controllers/thredded/post_previews_controller.rb +1 -0
- data/app/controllers/thredded/posts_controller.rb +1 -0
- data/app/controllers/thredded/preferences_controller.rb +4 -3
- data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -0
- data/app/controllers/thredded/private_post_previews_controller.rb +1 -0
- data/app/controllers/thredded/private_posts_controller.rb +1 -0
- data/app/controllers/thredded/private_topic_previews_controller.rb +1 -0
- data/app/controllers/thredded/private_topics_controller.rb +1 -0
- data/app/controllers/thredded/read_states_controller.rb +1 -0
- data/app/controllers/thredded/theme_previews_controller.rb +1 -0
- data/app/controllers/thredded/topic_previews_controller.rb +1 -0
- data/app/controllers/thredded/topics_controller.rb +5 -4
- data/app/forms/thredded/edit_topic_form.rb +1 -0
- data/app/forms/thredded/post_form.rb +2 -0
- data/app/forms/thredded/private_post_form.rb +2 -0
- data/app/forms/thredded/private_topic_form.rb +1 -0
- data/app/forms/thredded/topic_form.rb +1 -0
- data/app/forms/thredded/user_preferences_form.rb +1 -0
- data/app/helpers/thredded/application_helper.rb +1 -0
- data/app/helpers/thredded/nav_helper.rb +7 -6
- data/app/helpers/thredded/render_helper.rb +1 -0
- data/app/helpers/thredded/urls_helper.rb +1 -0
- data/app/jobs/thredded/activity_updater_job.rb +1 -0
- data/app/jobs/thredded/auto_follow_and_notify_job.rb +1 -0
- data/app/jobs/thredded/notify_private_topic_users_job.rb +1 -0
- data/app/mailer_previews/thredded/base_mailer_preview.rb +2 -1
- data/app/mailer_previews/thredded/post_mailer_preview.rb +3 -2
- data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +2 -1
- data/app/mailers/thredded/base_mailer.rb +1 -0
- data/app/mailers/thredded/post_mailer.rb +1 -0
- data/app/mailers/thredded/private_topic_mailer.rb +1 -0
- data/app/models/concerns/thredded/content_moderation_state.rb +1 -0
- data/app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb +1 -0
- data/app/models/concerns/thredded/moderation_state.rb +2 -1
- data/app/models/concerns/thredded/notifier_preference.rb +1 -0
- data/app/models/concerns/thredded/post_common.rb +1 -0
- data/app/models/concerns/thredded/search_parser.rb +3 -2
- data/app/models/concerns/thredded/topic_common.rb +2 -1
- data/app/models/concerns/thredded/topics_search.rb +1 -0
- data/app/models/concerns/thredded/user_topic_read_state_common.rb +1 -0
- data/app/models/thredded/category.rb +2 -1
- data/app/models/thredded/messageboard.rb +5 -4
- data/app/models/thredded/messageboard_group.rb +1 -0
- data/app/models/thredded/messageboard_notifications_for_followed_topics.rb +2 -1
- data/app/models/thredded/messageboard_user.rb +1 -0
- data/app/models/thredded/notifications_for_followed_topics.rb +2 -1
- data/app/models/thredded/notifications_for_private_topics.rb +2 -1
- data/app/models/thredded/null_user.rb +1 -0
- data/app/models/thredded/null_user_topic_read_state.rb +1 -0
- data/app/models/thredded/post.rb +4 -3
- data/app/models/thredded/post_moderation_record.rb +3 -2
- data/app/models/thredded/private_post.rb +3 -2
- data/app/models/thredded/private_topic.rb +4 -3
- data/app/models/thredded/private_user.rb +2 -1
- data/app/models/thredded/stats.rb +1 -0
- data/app/models/thredded/topic.rb +6 -5
- data/app/models/thredded/topic_category.rb +1 -0
- data/app/models/thredded/user_detail.rb +2 -1
- data/app/models/thredded/user_extender.rb +2 -1
- data/app/models/thredded/user_messageboard_preference.rb +2 -1
- data/app/models/thredded/user_permissions/admin/if_admin_column_true.rb +1 -0
- data/app/models/thredded/user_permissions/admin/none.rb +1 -0
- data/app/models/thredded/user_permissions/message/readers_of_writeable_boards.rb +1 -0
- data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +1 -0
- data/app/models/thredded/user_permissions/moderate/none.rb +1 -0
- data/app/models/thredded/user_permissions/read/all.rb +1 -0
- data/app/models/thredded/user_permissions/write/all.rb +1 -0
- data/app/models/thredded/user_permissions/write/none.rb +1 -0
- data/app/models/thredded/user_post_notification.rb +2 -1
- data/app/models/thredded/user_preference.rb +2 -1
- data/app/models/thredded/user_private_topic_read_state.rb +2 -1
- data/app/models/thredded/user_topic_follow.rb +3 -2
- data/app/models/thredded/user_topic_read_state.rb +2 -1
- data/app/notifiers/thredded/base_notifier.rb +1 -1
- data/app/notifiers/thredded/email_notifier.rb +1 -0
- data/app/policies/thredded/messageboard_group_policy.rb +1 -0
- data/app/policies/thredded/messageboard_policy.rb +1 -0
- data/app/policies/thredded/post_policy.rb +1 -0
- data/app/policies/thredded/private_post_policy.rb +1 -0
- data/app/policies/thredded/private_topic_policy.rb +1 -0
- data/app/policies/thredded/topic_policy.rb +1 -0
- data/app/view_hooks/thredded/all_view_hooks.rb +1 -0
- data/app/view_models/thredded/base_topic_view.rb +1 -0
- data/app/view_models/thredded/messageboard_group_view.rb +1 -0
- data/app/view_models/thredded/post_view.rb +1 -0
- data/app/view_models/thredded/posts_page_view.rb +1 -0
- data/app/view_models/thredded/private_topic_view.rb +1 -0
- data/app/view_models/thredded/private_topics_page_view.rb +1 -0
- data/app/view_models/thredded/topic_email_view.rb +1 -0
- data/app/view_models/thredded/topic_posts_page_view.rb +1 -0
- data/app/view_models/thredded/topic_view.rb +1 -0
- data/app/view_models/thredded/topics_page_view.rb +1 -0
- data/app/views/thredded/messageboards/index.html.erb +2 -2
- data/app/views/thredded/posts_common/actions/_edit.html.erb +2 -1
- data/app/views/thredded/private_topics/_header.html.erb +2 -1
- data/app/views/thredded/topics/_header.html.erb +2 -1
- data/app/views/thredded/topics/index.html.erb +1 -1
- data/bin/rails +1 -0
- data/bin/rubocop +1 -0
- data/config/routes.rb +13 -12
- data/db/migrate/20160329231848_create_thredded.rb +75 -66
- data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +6 -3
- data/db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb +4 -1
- data/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb +4 -1
- data/db/upgrade_migrations/20161113161801_upgrade_v0_8_to_v0_9.rb +11 -8
- data/db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb +12 -6
- data/db/upgrade_migrations/20170312131417_upgrade_thredded_v0_10_to_v0_11.rb +6 -3
- data/db/upgrade_migrations/20170420163138_upgrade_thredded_v0_11_to_v0_12.rb +4 -1
- data/lib/generators/thredded/install/install_generator.rb +1 -0
- data/lib/generators/thredded/install/templates/initializer.rb +1 -0
- data/lib/tasks/thredded_tasks.rake +1 -0
- data/lib/thredded.rb +7 -0
- data/lib/thredded/base_migration.rb +14 -0
- data/lib/thredded/collection_to_strings_with_cache_renderer.rb +1 -0
- data/lib/thredded/content_formatter.rb +7 -6
- data/lib/thredded/database_seeder.rb +1 -0
- data/lib/thredded/db_tools.rb +9 -8
- data/lib/thredded/email_transformer.rb +1 -0
- data/lib/thredded/email_transformer/onebox.rb +1 -0
- data/lib/thredded/engine.rb +3 -2
- data/lib/thredded/errors.rb +1 -0
- data/lib/thredded/formatting_demo_content.rb +1 -0
- data/lib/thredded/html_pipeline/at_mention_filter.rb +3 -2
- data/lib/thredded/html_pipeline/autolink_filter.rb +1 -0
- data/lib/thredded/html_pipeline/kramdown_filter.rb +2 -1
- data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
- data/lib/thredded/html_pipeline/wrap_iframes_filter.rb +1 -0
- data/lib/thredded/version.rb +2 -1
- data/lib/thredded/view_hooks/config.rb +1 -0
- data/lib/thredded/view_hooks/renderer.rb +1 -0
- metadata +5 -7
- data/db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb +0 -63
- data/db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb +0 -13
- data/db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb +0 -56
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Thredded
|
3
4
|
# Delivery records for Thredded::Post notifications.
|
4
5
|
class UserPostNotification < ActiveRecord::Base
|
5
|
-
belongs_to :user, class_name: Thredded.
|
6
|
+
belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_post_notifications
|
6
7
|
belongs_to :post, class_name: 'Thredded::Post', inverse_of: :user_notifications
|
7
8
|
|
8
9
|
# @param post [Thredded::Post]
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Thredded
|
3
4
|
class UserPreference < ActiveRecord::Base
|
4
|
-
belongs_to :user, class_name: Thredded.
|
5
|
+
belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_user_preference
|
5
6
|
|
6
7
|
with_options(inverse_of: :user_preference, primary_key: :user_id, foreign_key: :user_id,
|
7
8
|
dependent: :destroy) do |opt|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Thredded
|
3
4
|
class UserPrivateTopicReadState < ActiveRecord::Base
|
4
5
|
include Thredded::UserTopicReadStateCommon
|
5
6
|
belongs_to :user,
|
6
|
-
class_name: Thredded.
|
7
|
+
class_name: Thredded.user_class_name,
|
7
8
|
inverse_of: :thredded_private_topic_read_states
|
8
9
|
belongs_to :postable,
|
9
10
|
class_name: 'Thredded::PrivateTopic',
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Thredded
|
3
4
|
class UserTopicFollow < ActiveRecord::Base
|
4
|
-
enum reason: [
|
5
|
+
enum reason: %i[manual posted mentioned auto]
|
5
6
|
|
6
|
-
belongs_to :user, inverse_of: :thredded_topic_follows, class_name: Thredded.
|
7
|
+
belongs_to :user, inverse_of: :thredded_topic_follows, class_name: Thredded.user_class_name
|
7
8
|
belongs_to :topic, inverse_of: :user_follows
|
8
9
|
|
9
10
|
validates :user_id, presence: true
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Thredded
|
3
4
|
class UserTopicReadState < ActiveRecord::Base
|
4
5
|
include Thredded::UserTopicReadStateCommon
|
5
6
|
belongs_to :user,
|
6
|
-
class_name: Thredded.
|
7
|
+
class_name: Thredded.user_class_name,
|
7
8
|
inverse_of: :thredded_topic_read_states
|
8
9
|
belongs_to :postable,
|
9
10
|
class_name: 'Thredded::Topic',
|
@@ -6,7 +6,7 @@ module Thredded
|
|
6
6
|
unless notifier.respond_to?(:key) && /^[a-z_]+$/.match(notifier.key)
|
7
7
|
fail "Notifier problem: #{notifier.class.name} must respond to #key with a snake_case string"
|
8
8
|
end
|
9
|
-
[
|
9
|
+
%i[human_name new_post new_private_post].each do |m|
|
10
10
|
unless notifier.respond_to?(m)
|
11
11
|
fail "#{notifier.class.name} must respond to ##{m}"
|
12
12
|
end
|
@@ -19,12 +19,12 @@
|
|
19
19
|
|
20
20
|
<div class="thredded--messageboards--actions">
|
21
21
|
<% if policy(Thredded::Messageboard.new).create? %>
|
22
|
-
<a class="thredded--button" href="<%= new_messageboard_path %>">
|
22
|
+
<a class="thredded--button" href="<%= new_messageboard_path %>" rel="nofollow">
|
23
23
|
<%= t('thredded.messageboard.create') %>
|
24
24
|
</a>
|
25
25
|
<% end %>
|
26
26
|
<% if policy(Thredded::MessageboardGroup.new).create? %>
|
27
|
-
<a class="thredded--button" href="<%= new_messageboard_group_path %>">
|
27
|
+
<a class="thredded--button" href="<%= new_messageboard_group_path %>" rel="nofollow">
|
28
28
|
<%= t('thredded.messageboard_group.create') %>
|
29
29
|
</a>
|
30
30
|
<% end %>
|
@@ -7,7 +7,8 @@
|
|
7
7
|
</cite>
|
8
8
|
<% if topic.can_update? %>
|
9
9
|
<%= link_to t('thredded.topics.edit'), topic.edit_path,
|
10
|
-
class: 'thredded--topic-header--edit-topic'
|
10
|
+
class: 'thredded--topic-header--edit-topic',
|
11
|
+
rel: 'nofollow' %>
|
11
12
|
<% end %>
|
12
13
|
<% if thredded_current_user %>
|
13
14
|
<% if topic.followed? %>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
<div class="thredded--messageboards--actions">
|
24
24
|
<% if policy(messageboard).update? %>
|
25
|
-
<a class="thredded--button" href="<%= edit_messageboard_path(messageboard) %>">
|
25
|
+
<a class="thredded--button" href="<%= edit_messageboard_path(messageboard) %>" rel="nofollow">
|
26
26
|
<%= t('thredded.nav.edit_messageboard') %>
|
27
27
|
</a>
|
28
28
|
<% end %>
|
data/bin/rails
CHANGED
data/bin/rubocop
CHANGED
data/config/routes.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
|
3
|
-
resource :theme_preview, only: [:show], path: 'theme-preview' if %w
|
4
|
+
resource :theme_preview, only: [:show], path: 'theme-preview' if %w[development test].include? Rails.env
|
4
5
|
|
5
6
|
page_constraint = { page: /[1-9]\d*/ }
|
6
7
|
|
@@ -9,11 +10,11 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
|
|
9
10
|
resource :private_topic, only: [:new], path: '' do
|
10
11
|
post :preview, on: :new, controller: 'private_topic_previews'
|
11
12
|
end
|
12
|
-
resources :private_topics, except: [
|
13
|
+
resources :private_topics, except: %i[new show], path: '' do
|
13
14
|
member do
|
14
15
|
get '(page-:page)', action: :show, as: '', constraints: page_constraint
|
15
16
|
end
|
16
|
-
resources :private_posts, path: '', except: [
|
17
|
+
resources :private_posts, path: '', except: %i[index show] do
|
17
18
|
post :preview, on: :new, controller: 'private_post_previews'
|
18
19
|
resource :preview, only: [:update], controller: 'private_post_previews'
|
19
20
|
member do
|
@@ -37,7 +38,7 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
|
|
37
38
|
end
|
38
39
|
|
39
40
|
scope path: 'admin' do
|
40
|
-
resources :messageboard_groups, only: [
|
41
|
+
resources :messageboard_groups, only: %i[new create]
|
41
42
|
scope controller: :moderation, path: 'moderation' do
|
42
43
|
scope constraints: page_constraint do
|
43
44
|
get '(/page-:page)', action: :pending, as: :pending_moderation
|
@@ -51,15 +52,15 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
|
-
resource :preferences, only: [
|
55
|
+
resource :preferences, only: %i[edit update], as: :global_preferences
|
55
56
|
resource :messageboard, path: 'messageboards', only: [:new]
|
56
|
-
resources :messageboards, only: [
|
57
|
-
resources :messageboards, only: [
|
58
|
-
resource :preferences, only: [
|
57
|
+
resources :messageboards, only: %i[edit update]
|
58
|
+
resources :messageboards, only: %i[index create], path: '' do
|
59
|
+
resource :preferences, only: %i[edit update]
|
59
60
|
resource :topic, path: 'topics', only: [:new] do
|
60
61
|
post :preview, on: :new, controller: 'topic_previews'
|
61
62
|
end
|
62
|
-
resources :topics, path: '', except: [
|
63
|
+
resources :topics, path: '', except: %i[index new show] do
|
63
64
|
collection do
|
64
65
|
get '(page-:page)', action: :index, as: '', constraints: page_constraint
|
65
66
|
get '/category/:category_id', action: :category, as: :categories
|
@@ -68,10 +69,10 @@ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
|
|
68
69
|
get '(page-:page)', action: :show, as: '', constraints: page_constraint
|
69
70
|
|
70
71
|
# match (un)follow via get as well so that redirecting back to it after sign in works.
|
71
|
-
match 'follow', via: [
|
72
|
-
match 'unfollow', via: [
|
72
|
+
match 'follow', via: %i[post get]
|
73
|
+
match 'unfollow', via: %i[post get]
|
73
74
|
end
|
74
|
-
resources :posts, except: [
|
75
|
+
resources :posts, except: %i[index show], path: '' do
|
75
76
|
post :preview, on: :new, controller: 'post_previews'
|
76
77
|
resource :preview, only: [:update], controller: 'post_previews'
|
77
78
|
member do
|
@@ -1,32 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thredded/base_migration'
|
4
|
+
|
2
5
|
# rubocop:disable Metrics/ClassLength
|
3
6
|
# rubocop:disable Metrics/MethodLength
|
4
|
-
class CreateThredded <
|
7
|
+
class CreateThredded < Thredded::BaseMigration
|
5
8
|
def change
|
6
9
|
unless table_exists?(:friendly_id_slugs)
|
7
10
|
# The user might have installed FriendlyId separately already.
|
8
11
|
create_table :friendly_id_slugs do |t|
|
9
|
-
t.string :slug,
|
12
|
+
t.string :slug, null: false
|
10
13
|
t.integer :sluggable_id, null: false
|
11
14
|
t.string :sluggable_type, limit: 50
|
12
|
-
t.string :scope
|
13
|
-
t.datetime :created_at
|
14
|
-
t.index [:slug, :sluggable_type, :scope],
|
15
|
-
name: :index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope,
|
16
|
-
unique: true
|
17
|
-
t.index [:slug, :sluggable_type], name: :index_friendly_id_slugs_on_slug_and_sluggable_type
|
18
|
-
t.index [:sluggable_id], name: :index_friendly_id_slugs_on_sluggable_id
|
19
|
-
t.index [:sluggable_type], name: :index_friendly_id_slugs_on_sluggable_type
|
15
|
+
t.string :scope
|
16
|
+
t.datetime :created_at
|
20
17
|
end
|
18
|
+
add_index :friendly_id_slugs, :sluggable_id
|
19
|
+
add_index :friendly_id_slugs, %i[slug sluggable_type], length: { slug: 140, sluggable_type: 50 }
|
20
|
+
add_index :friendly_id_slugs, %i[slug sluggable_type scope],
|
21
|
+
length: { slug: 70, sluggable_type: 50, scope: 70 },
|
22
|
+
unique: true
|
23
|
+
add_index :friendly_id_slugs, :sluggable_type
|
21
24
|
end
|
22
25
|
|
23
26
|
create_table :thredded_categories do |t|
|
24
|
-
t.references :messageboard, null: false
|
27
|
+
t.references :messageboard, null: false, index: false
|
25
28
|
t.string :name, limit: 191, null: false
|
26
29
|
t.string :description, limit: 255
|
27
30
|
t.timestamps null: false
|
28
31
|
t.string :slug, limit: 191, null: false
|
29
|
-
t.index [
|
32
|
+
t.index %i[messageboard_id slug], name: :index_thredded_categories_on_messageboard_id_and_slug, unique: true
|
30
33
|
t.index [:messageboard_id], name: :index_thredded_categories_on_messageboard_id
|
31
34
|
end
|
32
35
|
DbTextSearch::CaseInsensitive.add_index connection, :thredded_categories, :name, name: :thredded_categories_name_ci
|
@@ -38,23 +41,23 @@ class CreateThredded < ActiveRecord::Migration
|
|
38
41
|
t.integer :topics_count, default: 0
|
39
42
|
t.integer :posts_count, default: 0
|
40
43
|
t.integer :position, null: false
|
41
|
-
t.references :last_topic
|
42
|
-
t.references :messageboard_group
|
44
|
+
t.references :last_topic, index: false
|
45
|
+
t.references :messageboard_group, index: false
|
43
46
|
t.timestamps null: false
|
44
47
|
t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
|
45
48
|
t.index [:slug], name: :index_thredded_messageboards_on_slug
|
46
49
|
end
|
47
50
|
|
48
51
|
create_table :thredded_posts do |t|
|
49
|
-
t.
|
52
|
+
t.references :user, type: user_id_type, index: false
|
50
53
|
t.text :content, limit: 65_535
|
51
54
|
t.string :ip, limit: 255
|
52
55
|
t.string :source, limit: 255, default: 'web'
|
53
|
-
t.references :postable, null: false
|
54
|
-
t.references :messageboard, null: false
|
56
|
+
t.references :postable, null: false, index: false
|
57
|
+
t.references :messageboard, null: false, index: false
|
55
58
|
t.integer :moderation_state, null: false
|
56
59
|
t.timestamps null: false
|
57
|
-
t.index [
|
60
|
+
t.index %i[moderation_state updated_at],
|
58
61
|
order: { updated_at: :asc },
|
59
62
|
name: :index_thredded_posts_for_display
|
60
63
|
t.index [:messageboard_id], name: :index_thredded_posts_on_messageboard_id
|
@@ -65,16 +68,16 @@ class CreateThredded < ActiveRecord::Migration
|
|
65
68
|
DbTextSearch::FullText.add_index connection, :thredded_posts, :content, name: :thredded_posts_content_fts
|
66
69
|
|
67
70
|
create_table :thredded_private_posts do |t|
|
68
|
-
t.references :user
|
71
|
+
t.references :user, type: user_id_type, index: false
|
69
72
|
t.text :content, limit: 65_535
|
70
|
-
t.references :postable, null: false
|
73
|
+
t.references :postable, null: false, index: false
|
71
74
|
t.string :ip, limit: 255
|
72
75
|
t.timestamps null: false
|
73
76
|
end
|
74
77
|
|
75
78
|
create_table :thredded_private_topics do |t|
|
76
|
-
t.references :user
|
77
|
-
t.references :last_user
|
79
|
+
t.references :user, type: user_id_type, index: false
|
80
|
+
t.references :last_user, index: false
|
78
81
|
t.string :title, limit: 255, null: false
|
79
82
|
t.string :slug, limit: 191, null: false
|
80
83
|
t.integer :posts_count, default: 0
|
@@ -86,26 +89,26 @@ class CreateThredded < ActiveRecord::Migration
|
|
86
89
|
end
|
87
90
|
|
88
91
|
create_table :thredded_private_users do |t|
|
89
|
-
t.references :private_topic,
|
90
|
-
t.references :user,
|
92
|
+
t.references :private_topic, index: false
|
93
|
+
t.references :user, type: user_id_type, index: false
|
91
94
|
t.timestamps null: false
|
92
95
|
t.index [:private_topic_id], name: :index_thredded_private_users_on_private_topic_id
|
93
96
|
t.index [:user_id], name: :index_thredded_private_users_on_user_id
|
94
97
|
end
|
95
98
|
|
96
99
|
create_table :thredded_topic_categories do |t|
|
97
|
-
t.references :topic, null: false
|
98
|
-
t.references :category, null: false
|
100
|
+
t.references :topic, null: false, index: false
|
101
|
+
t.references :category, null: false, index: false
|
99
102
|
t.index [:category_id], name: :index_thredded_topic_categories_on_category_id
|
100
103
|
t.index [:topic_id], name: :index_thredded_topic_categories_on_topic_id
|
101
104
|
end
|
102
105
|
|
103
106
|
create_table :thredded_topics do |t|
|
104
|
-
t.references :user
|
105
|
-
t.references :last_user
|
107
|
+
t.references :user, type: user_id_type, index: false
|
108
|
+
t.references :last_user, index: false
|
106
109
|
t.string :title, limit: 255, null: false
|
107
110
|
t.string :slug, limit: 191, null: false
|
108
|
-
t.references :messageboard, null: false
|
111
|
+
t.references :messageboard, null: false, index: false
|
109
112
|
t.integer :posts_count, default: 0, null: false
|
110
113
|
t.boolean :sticky, default: false, null: false
|
111
114
|
t.boolean :locked, default: false, null: false
|
@@ -114,7 +117,7 @@ class CreateThredded < ActiveRecord::Migration
|
|
114
117
|
t.integer :moderation_state, null: false
|
115
118
|
t.datetime :last_post_at
|
116
119
|
t.timestamps null: false
|
117
|
-
t.index %i
|
120
|
+
t.index %i[moderation_state sticky updated_at],
|
118
121
|
order: { sticky: :desc, updated_at: :desc },
|
119
122
|
name: :index_thredded_topics_for_display
|
120
123
|
t.index [:hash_id], name: :index_thredded_topics_on_hash_id
|
@@ -125,7 +128,7 @@ class CreateThredded < ActiveRecord::Migration
|
|
125
128
|
DbTextSearch::FullText.add_index connection, :thredded_topics, :title, name: :thredded_topics_title_fts
|
126
129
|
|
127
130
|
create_table :thredded_user_details do |t|
|
128
|
-
t.references :user, null: false
|
131
|
+
t.references :user, type: user_id_type, null: false, index: false
|
129
132
|
t.datetime :latest_activity_at
|
130
133
|
t.integer :posts_count, default: 0
|
131
134
|
t.integer :topics_count, default: 0
|
@@ -133,25 +136,29 @@ class CreateThredded < ActiveRecord::Migration
|
|
133
136
|
t.integer :moderation_state, null: false, default: 0 # pending_moderation
|
134
137
|
t.timestamp :moderation_state_changed_at
|
135
138
|
t.timestamps null: false
|
136
|
-
t.index %i
|
139
|
+
t.index %i[moderation_state moderation_state_changed_at],
|
137
140
|
order: { moderation_state_changed_at: :desc },
|
138
141
|
name: :index_thredded_user_details_for_moderations
|
139
|
-
t.index %i
|
140
|
-
t.index %i
|
142
|
+
t.index %i[latest_activity_at], name: :index_thredded_user_details_on_latest_activity_at
|
143
|
+
t.index %i[user_id], name: :index_thredded_user_details_on_user_id
|
141
144
|
end
|
142
145
|
|
143
146
|
create_table :thredded_messageboard_users do |t|
|
144
|
-
t.references :thredded_user_detail,
|
145
|
-
t.references :thredded_messageboard,
|
147
|
+
t.references :thredded_user_detail, null: false, index: false
|
148
|
+
t.references :thredded_messageboard, null: false, index: false
|
146
149
|
t.datetime :last_seen_at, null: false
|
147
|
-
t.index [
|
150
|
+
t.index %i[thredded_messageboard_id thredded_user_detail_id],
|
148
151
|
name: :index_thredded_messageboard_users_primary
|
149
|
-
t.index [
|
152
|
+
t.index %i[thredded_messageboard_id last_seen_at],
|
150
153
|
name: :index_thredded_messageboard_users_for_recently_active
|
151
154
|
end
|
155
|
+
add_foreign_key :thredded_messageboard_users, :thredded_user_details,
|
156
|
+
column: :thredded_user_detail_id, on_delete: :cascade
|
157
|
+
add_foreign_key :thredded_messageboard_users, :thredded_messageboards,
|
158
|
+
column: :thredded_messageboard_id, on_delete: :cascade
|
152
159
|
|
153
160
|
create_table :thredded_user_preferences do |t|
|
154
|
-
t.references :user, null: false
|
161
|
+
t.references :user, type: user_id_type, null: false, index: false
|
155
162
|
t.boolean :follow_topics_on_mention, default: true, null: false
|
156
163
|
t.boolean :auto_follow_topics, default: false, null: false
|
157
164
|
t.timestamps null: false
|
@@ -159,24 +166,24 @@ class CreateThredded < ActiveRecord::Migration
|
|
159
166
|
end
|
160
167
|
|
161
168
|
create_table :thredded_user_messageboard_preferences do |t|
|
162
|
-
t.references :user, null: false
|
163
|
-
t.references :messageboard, null: false
|
169
|
+
t.references :user, type: user_id_type, null: false, index: false
|
170
|
+
t.references :messageboard, null: false, index: false
|
164
171
|
t.boolean :follow_topics_on_mention, default: true, null: false
|
165
172
|
t.boolean :auto_follow_topics, default: false, null: false
|
166
173
|
t.timestamps null: false
|
167
|
-
t.index [
|
174
|
+
t.index %i[user_id messageboard_id],
|
168
175
|
name: :thredded_user_messageboard_preferences_user_id_messageboard_id,
|
169
176
|
unique: true
|
170
177
|
end
|
171
178
|
|
172
|
-
%i
|
179
|
+
%i[topic private_topic].each do |topics_table|
|
173
180
|
table_name = :"thredded_user_#{topics_table}_read_states"
|
174
181
|
create_table table_name do |t|
|
175
|
-
t.references :user, null: false
|
176
|
-
t.
|
182
|
+
t.references :user, type: user_id_type, null: false, index: false
|
183
|
+
t.references :postable, null: false, index: false
|
177
184
|
t.integer :page, default: 1, null: false
|
178
185
|
t.timestamp :read_at, null: false
|
179
|
-
t.index [
|
186
|
+
t.index %i[user_id postable_id], name: :"#{table_name}_user_postable", unique: true
|
180
187
|
end
|
181
188
|
end
|
182
189
|
|
@@ -187,60 +194,62 @@ class CreateThredded < ActiveRecord::Migration
|
|
187
194
|
end
|
188
195
|
|
189
196
|
create_table :thredded_user_topic_follows do |t|
|
190
|
-
t.references :user, null: false
|
191
|
-
t.
|
197
|
+
t.references :user, type: user_id_type, null: false, index: false
|
198
|
+
t.references :topic, null: false, index: false
|
192
199
|
t.datetime :created_at, null: false
|
193
200
|
t.integer :reason, limit: 1
|
194
|
-
t.index [
|
201
|
+
t.index %i[user_id topic_id], name: :thredded_user_topic_follows_user_topic, unique: true
|
195
202
|
end
|
196
203
|
|
197
204
|
create_table :thredded_post_moderation_records do |t|
|
198
|
-
t.references :post
|
199
|
-
t.references :messageboard
|
205
|
+
t.references :post, index: false
|
206
|
+
t.references :messageboard, index: false
|
200
207
|
t.text :post_content, limit: 65_535
|
201
|
-
t.references :post_user
|
208
|
+
t.references :post_user, index: false
|
202
209
|
t.text :post_user_name
|
203
|
-
t.references :moderator
|
210
|
+
t.references :moderator, index: false
|
204
211
|
t.integer :moderation_state, null: false
|
205
212
|
t.integer :previous_moderation_state, null: false
|
206
213
|
t.timestamp :created_at, null: false
|
207
|
-
t.index [
|
214
|
+
t.index %i[messageboard_id created_at],
|
208
215
|
order: { created_at: :desc },
|
209
216
|
name: :index_thredded_moderation_records_for_display
|
210
217
|
end
|
211
218
|
|
212
219
|
create_table :thredded_notifications_for_private_topics do |t|
|
213
|
-
t.
|
220
|
+
t.references :user, null: false, index: false, type: user_id_type
|
214
221
|
t.string :notifier_key, null: false, limit: 90
|
215
222
|
t.boolean :enabled, default: true, null: false
|
216
|
-
t.index [
|
223
|
+
t.index %i[user_id notifier_key],
|
217
224
|
name: 'thredded_notifications_for_private_topics_unique', unique: true
|
218
225
|
end
|
219
226
|
create_table :thredded_notifications_for_followed_topics do |t|
|
220
|
-
t.
|
227
|
+
t.references :user, null: false, index: false, type: user_id_type
|
221
228
|
t.string :notifier_key, null: false, limit: 90
|
222
229
|
t.boolean :enabled, default: true, null: false
|
223
|
-
t.index [
|
230
|
+
t.index %i[user_id notifier_key],
|
224
231
|
name: 'thredded_notifications_for_followed_topics_unique', unique: true
|
225
232
|
end
|
226
233
|
create_table :thredded_messageboard_notifications_for_followed_topics do |t|
|
227
|
-
t.
|
228
|
-
t.
|
234
|
+
t.references :user, null: false, index: false, type: user_id_type
|
235
|
+
t.references :messageboard, null: false, index: false
|
229
236
|
t.string :notifier_key, null: false, limit: 90
|
230
237
|
t.boolean :enabled, default: true, null: false
|
231
|
-
t.index [
|
238
|
+
t.index %i[user_id messageboard_id notifier_key],
|
232
239
|
name: 'thredded_messageboard_notifications_for_followed_topics_unique', unique: true
|
233
240
|
end
|
234
241
|
|
235
242
|
create_table :thredded_user_post_notifications do |t|
|
236
|
-
t.references :user, null: false
|
237
|
-
t.
|
238
|
-
t.references :post, null: false
|
239
|
-
t.foreign_key :thredded_posts, column: :post_id, on_delete: :cascade
|
243
|
+
t.references :user, null: false, index: false, type: user_id_type
|
244
|
+
t.references :post, null: false, index: false
|
240
245
|
t.datetime :notified_at, null: false
|
241
246
|
t.index :post_id, name: :index_thredded_user_post_notifications_on_post_id
|
242
|
-
t.index [
|
247
|
+
t.index %i[user_id post_id], name: :index_thredded_user_post_notifications_on_user_id_and_post_id, unique: true
|
243
248
|
end
|
249
|
+
add_foreign_key :thredded_user_post_notifications,
|
250
|
+
Thredded.user_class.table_name, column: :user_id, on_delete: :cascade
|
251
|
+
add_foreign_key :thredded_user_post_notifications,
|
252
|
+
:thredded_posts, column: :post_id, on_delete: :cascade
|
244
253
|
end
|
245
254
|
end
|
246
255
|
# rubocop:enable Metrics/MethodLength
|