thredded 0.8.4 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -9
  3. data/app/assets/images/thredded/breadcrumb-chevron.svg +1 -1
  4. data/app/assets/images/thredded/follow.svg +1 -1
  5. data/app/assets/images/thredded/moderation.svg +1 -4
  6. data/app/assets/images/thredded/private-messages.svg +1 -4
  7. data/app/assets/images/thredded/settings.svg +1 -4
  8. data/app/assets/images/thredded/unfollow.svg +1 -1
  9. data/app/assets/javascripts/thredded/components/time_stamps.es6 +1 -1
  10. data/app/assets/javascripts/thredded/components/user_preferences_form.es6 +26 -49
  11. data/app/assets/javascripts/thredded/dependencies.js +2 -1
  12. data/app/assets/stylesheets/thredded/base/_grid.scss +4 -4
  13. data/app/assets/stylesheets/thredded/base/_typography.scss +18 -0
  14. data/app/assets/stylesheets/thredded/components/_base.scss +4 -0
  15. data/app/assets/stylesheets/thredded/components/_currently-online.scss +4 -0
  16. data/app/assets/stylesheets/thredded/components/_form-list.scss +5 -0
  17. data/app/assets/stylesheets/thredded/components/_messageboard.scss +3 -0
  18. data/app/assets/stylesheets/thredded/components/_post-form.scss +7 -4
  19. data/app/assets/stylesheets/thredded/components/_post.scss +3 -0
  20. data/app/assets/stylesheets/thredded/components/_topic-delete.scss +3 -0
  21. data/app/assets/stylesheets/thredded/components/_topic-header.scss +20 -0
  22. data/app/assets/stylesheets/thredded/components/_topics.scss +13 -1
  23. data/app/assets/stylesheets/thredded/layout/_main-navigation.scss +1 -1
  24. data/app/assets/stylesheets/thredded/layout/_navigation.scss +3 -1
  25. data/app/assets/stylesheets/thredded/layout/_search-navigation.scss +4 -0
  26. data/app/assets/stylesheets/thredded/layout/_user-navigation.scss +3 -0
  27. data/app/commands/thredded/at_notification_extractor.rb +1 -2
  28. data/app/commands/thredded/autofollow_mentioned_users.rb +0 -1
  29. data/app/commands/thredded/notify_following_users.rb +20 -11
  30. data/app/commands/thredded/notify_private_topic_users.rb +12 -28
  31. data/app/controllers/thredded/application_controller.rb +8 -4
  32. data/app/controllers/thredded/messageboards_controller.rb +2 -2
  33. data/app/controllers/thredded/moderation_controller.rb +12 -13
  34. data/app/controllers/thredded/posts_controller.rb +1 -1
  35. data/app/controllers/thredded/preferences_controller.rb +11 -7
  36. data/app/controllers/thredded/private_topics_controller.rb +13 -9
  37. data/app/controllers/thredded/topics_controller.rb +20 -12
  38. data/app/forms/thredded/user_preferences_form.rb +23 -4
  39. data/app/helpers/thredded/application_helper.rb +11 -1
  40. data/app/mailers/thredded/post_mailer.rb +2 -3
  41. data/app/mailers/thredded/private_topic_mailer.rb +2 -3
  42. data/app/models/concerns/thredded/content_moderation_state.rb +1 -1
  43. data/app/models/concerns/thredded/notifier_preference.rb +18 -0
  44. data/app/models/concerns/thredded/post_common.rb +5 -1
  45. data/{lib → app/models/concerns}/thredded/search_parser.rb +0 -0
  46. data/app/models/concerns/thredded/topic_common.rb +3 -3
  47. data/{lib → app/models/concerns}/thredded/topics_search.rb +2 -3
  48. data/app/models/thredded/messageboard.rb +11 -0
  49. data/app/models/thredded/messageboard_notifications_for_followed_topics.rb +29 -0
  50. data/app/models/thredded/notifications_for_followed_topics.rb +22 -0
  51. data/app/models/thredded/notifications_for_private_topics.rb +21 -0
  52. data/app/models/thredded/post.rb +5 -3
  53. data/app/models/thredded/post_moderation_record.rb +1 -1
  54. data/app/models/thredded/private_post.rb +1 -1
  55. data/app/models/thredded/private_topic.rb +8 -4
  56. data/app/models/thredded/stats.rb +1 -1
  57. data/app/models/thredded/topic.rb +10 -7
  58. data/app/models/thredded/user_detail.rb +1 -1
  59. data/app/models/thredded/user_extender.rb +3 -1
  60. data/app/models/thredded/user_preference.rb +16 -5
  61. data/app/models/thredded/user_private_topic_read_state.rb +1 -1
  62. data/app/models/thredded/user_topic_read_state.rb +1 -1
  63. data/app/notifiers/thredded/base_notifier.rb +28 -0
  64. data/app/notifiers/thredded/email_notifier.rb +34 -0
  65. data/app/policies/thredded/post_policy.rb +3 -4
  66. data/app/policies/thredded/private_post_policy.rb +2 -3
  67. data/app/policies/thredded/topic_policy.rb +1 -2
  68. data/app/view_hooks/thredded/all_view_hooks.rb +0 -3
  69. data/app/view_models/thredded/base_topic_view.rb +0 -1
  70. data/app/view_models/thredded/post_view.rb +0 -1
  71. data/app/view_models/thredded/posts_page_view.rb +1 -4
  72. data/app/view_models/thredded/private_topic_view.rb +3 -1
  73. data/app/view_models/thredded/private_topics_page_view.rb +8 -3
  74. data/app/view_models/thredded/topic_posts_page_view.rb +1 -2
  75. data/app/view_models/thredded/topic_view.rb +3 -3
  76. data/app/view_models/thredded/topics_page_view.rb +0 -1
  77. data/app/views/thredded/messageboard_groups/new.html.erb +5 -1
  78. data/app/views/thredded/messageboards/_form.html.erb +7 -2
  79. data/app/views/thredded/posts/_form.html.erb +2 -1
  80. data/app/views/thredded/posts/edit.html.erb +3 -2
  81. data/app/views/thredded/posts_common/_form.html.erb +6 -2
  82. data/app/views/thredded/preferences/_form.html.erb +41 -29
  83. data/app/views/thredded/private_posts/_form.html.erb +1 -0
  84. data/app/views/thredded/private_topics/_form.html.erb +3 -2
  85. data/app/views/thredded/private_topics/_header.html.erb +4 -0
  86. data/app/views/thredded/private_topics/_no_private_topics.html.erb +1 -1
  87. data/app/views/thredded/private_topics/_private_topic.html.erb +5 -2
  88. data/app/views/thredded/private_topics/edit.html.erb +2 -1
  89. data/app/views/thredded/private_topics/header/_participant.html.erb +1 -0
  90. data/app/views/thredded/private_topics/index.html.erb +6 -5
  91. data/app/views/thredded/private_topics/new.html.erb +0 -1
  92. data/app/views/thredded/private_topics/private_topic/_participant.html.erb +1 -0
  93. data/app/views/thredded/private_topics/show.html.erb +1 -3
  94. data/app/views/thredded/topics/_form.html.erb +1 -1
  95. data/app/views/thredded/topics/show.html.erb +4 -5
  96. data/config/locales/en.yml +22 -9
  97. data/config/locales/pt-BR.yml +22 -10
  98. data/config/routes.rb +1 -1
  99. data/db/migrate/20160329231848_create_thredded.rb +23 -3
  100. data/db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb +1 -1
  101. data/db/upgrade_migrations/20161113161801_upgrade_v0_8_to_v0_9.rb +56 -0
  102. data/lib/generators/thredded/install/templates/initializer.rb +28 -0
  103. data/lib/thredded.rb +32 -8
  104. data/lib/thredded/content_formatter.rb +3 -2
  105. data/lib/thredded/database_seeder.rb +11 -8
  106. data/lib/thredded/db_tools.rb +82 -0
  107. data/lib/thredded/html_pipeline/wrap_iframes_filter.rb +12 -0
  108. data/lib/thredded/version.rb +1 -1
  109. metadata +18 -8
  110. data/app/models/thredded/null_preference.rb +0 -16
@@ -5,6 +5,10 @@
5
5
  time_ago: time_ago(topic.created_at),
6
6
  user: user_link(topic.user) %>
7
7
  </cite>
8
+ <span class="thredded--topic-header--participants">
9
+ <%= render partial: 'thredded/private_topics/header/participant',
10
+ collection: (topic.users - [topic.user]) %>
11
+ </span>
8
12
  <% if topic.can_update? %>
9
13
  <%= link_to t('thredded.private_topics.edit'), topic.edit_path,
10
14
  class: 'thredded--topic-header--edit-topic' %>
@@ -1,6 +1,6 @@
1
1
  <div class="thredded--empty">
2
2
  <h3 class="thredded--empty--title"><%= t 'thredded.private_topics.no_private_topics.title' %></h3>
3
- <a class="thredded--button" href="<%= new_private_topic_path(messageboard) %>">
3
+ <a class="thredded--button" href="<%= new_private_topic_path %>">
4
4
  <%= t 'thredded.private_topics.no_private_topics.create_btn' %>
5
5
  </a>
6
6
  </div>
@@ -8,8 +8,11 @@
8
8
  </h1>
9
9
 
10
10
  <cite class="thredded--topics--updated-by">
11
- <%= time_ago private_topic.last_post_at%>
12
- <%= user_link private_topic.last_user %>
11
+ <%= time_ago private_topic.last_post_at %>
12
+ <span class="thredded--topics--participants">
13
+ <%= render partial: 'thredded/private_topics/private_topic/participant',
14
+ collection: [private_topic.last_user, *(private_topic.users - [private_topic.last_user])] %>
15
+ </span>
13
16
  </cite>
14
17
 
15
18
  <cite class="thredded--topics--started-by">
@@ -23,7 +23,8 @@
23
23
  required: true %>
24
24
  </li>
25
25
  <li>
26
- <button type="submit" class="thredded--form--submit">
26
+ <button type="submit" class="thredded--form--submit"
27
+ data-disable-with="<%= t 'thredded.private_topics.form.update_btn_submitting' %>">
27
28
  <%= t('thredded.private_topics.form.update_btn') %>
28
29
  </button>
29
30
  </li>
@@ -0,0 +1 @@
1
+ <span class="thredded--topic-header--participants--participant"><%= user_link participant %></span>
@@ -11,17 +11,18 @@
11
11
  <%= render 'thredded/private_topics/no_private_topics' %>
12
12
  <% else -%>
13
13
  <%= render 'thredded/private_topics/form',
14
- messageboard: messageboard,
15
14
  private_topic: @new_private_topic,
16
15
  css_class: 'thredded--is-compact',
17
16
  placeholder: t('thredded.private_topics.form.title_placeholder_start') %>
18
17
 
19
18
  <%= render @private_topics %>
20
19
 
21
- <%= link_to t('thredded.nav.mark_all_read'),
22
- mark_all_private_topics_read_path,
23
- class: 'thredded--button thredded--button-light thredded--button-wide',
24
- method: :put -%>
20
+ <% unless unread_private_topics_count.zero? %>
21
+ <%= link_to t('thredded.nav.mark_all_read'),
22
+ mark_all_private_topics_read_path,
23
+ class: 'thredded--button thredded--button-light thredded--button-wide',
24
+ method: :put -%>
25
+ <% end %>
25
26
  <% end -%>
26
27
  <% end %>
27
28
 
@@ -5,7 +5,6 @@
5
5
  <%= thredded_page do %>
6
6
  <section class="thredded--main-section">
7
7
  <%= render 'thredded/private_topics/form',
8
- messageboard: messageboard,
9
8
  private_topic: @private_topic,
10
9
  placeholder: t('thredded.private_topics.form.title_placeholder_new') if @private_topic %>
11
10
  </section>
@@ -0,0 +1 @@
1
+ <span class="thredded--topics--participants--participant"><%= user_link participant %></span>
@@ -9,11 +9,9 @@
9
9
  class: ['thredded--main-section', 'thredded--topic', *topic_css_classes(private_topic)] do %>
10
10
  <%= render 'thredded/private_topics/header', topic: private_topic %>
11
11
  <%= render partial: 'thredded/private_posts/private_post', collection: @posts, cached: true %>
12
+ <%= paginate @posts %>
12
13
  <%= render 'thredded/private_posts/form',
13
14
  topic: private_topic,
14
15
  post: @post %>
15
16
  <% end %>
16
- <footer>
17
- <%= paginate @posts %>
18
- </footer>
19
17
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <%= form_for [messageboard, topic],
2
2
  html: {
3
- class: "thredded--form #{local_assigns[:css_class]}",
3
+ class: "thredded--form thredded--new-topic-form #{local_assigns[:css_class]}",
4
4
  'data-thredded-topic-form' => true,
5
5
  'data-autocomplete-url' => autocomplete_users_path,
6
6
  'data-autocomplete-min-length' => Thredded.autocomplete_min_length,
@@ -9,13 +9,16 @@
9
9
  class: ['thredded--main-section', 'thredded--topic', *topic_css_classes(topic)] do %>
10
10
  <%= render 'thredded/topics/header', topic: topic %>
11
11
  <%= render partial: 'thredded/posts/post', collection: @posts, cached: true %>
12
+ <%= paginate @posts %>
13
+
12
14
  <% if policy(@new_post).create? %>
13
15
  <div class="thredded--post-form--wrapper">
14
16
  <h3 class="thredded--post-form--title">Add a post</h3>
15
17
  <%= render 'thredded/posts/form',
16
18
  topic: topic,
17
19
  post: @new_post,
18
- button_text: t('thredded.posts.form.create_btn') %>
20
+ button_text: t('thredded.posts.form.create_btn'),
21
+ button_submitting_text: t('thredded.posts.form.create_btn_submitting') %>
19
22
  </div>
20
23
  <% end %>
21
24
 
@@ -28,8 +31,4 @@
28
31
  </div>
29
32
  <% end %>
30
33
  <% end %>
31
-
32
- <footer>
33
- <%= paginate @posts %>
34
- </footer>
35
34
  <% end %>
@@ -4,17 +4,23 @@ en:
4
4
  content_moderation_states:
5
5
  content_blocked_notice: Blocked
6
6
  content_blocked_notice_with_record_html: Blocked by %{moderator} %{time_ago}
7
+ email_notifier:
8
+ by_email: by email
7
9
  errors:
8
10
  login_required: Please sign in first.
9
11
  not_authorized: You are not authorized to access this page.
10
12
  private_topic_create_denied: You are not authorized to create private topics.
11
13
  private_topic_not_found: This private topic does not exist.
12
14
  form:
15
+ create_btn_submitting: Creating...
13
16
  update: Update
17
+ update_btn_submitting: Updating...
14
18
  messageboard:
15
19
  create: Create a New Messageboard
16
20
  form:
21
+ create_btn_submitting: :thredded.form.create_btn_submitting
17
22
  no_group: No Group
23
+ update_btn_submitting: :thredded.form.update_btn_submitting
18
24
  index:
19
25
  page_title: Messageboards
20
26
  last_updated_by_html: Updated %{time_ago} <cite>by %{user}</cite>
@@ -23,6 +29,8 @@ en:
23
29
  updated_notice: Messageboard has been updated
24
30
  messageboard_group:
25
31
  create: Create a New Messageboard Group
32
+ form:
33
+ create_btn_submitting: :thredded.form.create_btn_submitting
26
34
  saved: Messageboard Group %{name} created
27
35
  moderation:
28
36
  approve_btn: Approve
@@ -65,7 +73,9 @@ en:
65
73
  form:
66
74
  content_label: Content
67
75
  create_btn: Submit Reply
76
+ create_btn_submitting: Posting...
68
77
  update_btn: Update Post
78
+ update_btn_submitting: :thredded.form.update_btn_submitting
69
79
  pending_moderation_notice: Your post will be published when it has been reviewed by a moderator.
70
80
  preferences:
71
81
  edit:
@@ -74,28 +84,28 @@ en:
74
84
  follow_topics_on_mention:
75
85
  hint: 'When someone mentions you by your username (eg: @sam) you will follow the topic.'
76
86
  label: Follow topics you are mentioned in
77
- followed_topic_emails:
78
- hint: When there is a post in a topic you follow you will receive an email.
79
- label: Email notifications for followed topics
80
87
  global_preferences_label: Global Settings
81
88
  messageboard_follow_topics_on_mention:
82
89
  hint: 'When someone mentions you by your username (eg: @sam) in this messageboard you will follow the
83
90
  topic.'
84
91
  label: :thredded.preferences.form.follow_topics_on_mention.label
85
- messageboard_followed_topic_emails:
86
- hint: When there is a post in a topic you follow on this messageboard you will be sent an email.
87
- label: Email notifications for followed topics
92
+ messageboard_notifications_for_followed_topics:
93
+ label: :thredded.preferences.form.notifications_for_followed_topics.label
88
94
  messageboard_preferences_label_html: Notification Settings for <em>%{messageboard}</em>
89
- notify_on_message:
90
- hint: When you are added to a private conversation you will receive an email with its content.
91
- label: Email notifications for private messages
95
+ notifications_for_followed_topics:
96
+ label: Notifications for followed topics
97
+ notifications_for_private_topics:
98
+ label: Notifications for private messages
92
99
  submit_btn: Update Settings
93
100
  title: Settings
101
+ update_btn_submitting: :thredded.form.update_btn_submitting
94
102
  updated_notice: Your settings have been updated.
95
103
  private_posts:
96
104
  form:
97
105
  content_label: Message
98
106
  create_btn: Send Message
107
+ create_btn_submitting: Sending...
108
+ update_btn_submitting: :thredded.form.update_btn_submitting
99
109
  private_topics:
100
110
  edit: Edit
101
111
  errors:
@@ -103,10 +113,12 @@ en:
103
113
  form:
104
114
  content_label: :thredded.private_posts.form.content_label
105
115
  create_btn: :thredded.private_posts.form.create_btn
116
+ create_btn_submitting: :thredded.private_posts.form.create_btn_submitting
106
117
  title_label: :thredded.topics.form.title_label
107
118
  title_placeholder_new: Write the subject of this conversation
108
119
  title_placeholder_start: Start a new conversation
109
120
  update_btn: Update
121
+ update_btn_submitting: :thredded.private_posts.form.update_btn_submitting
110
122
  users_label: Participants
111
123
  users_placeholder: Select users to participate in this conversation
112
124
  no_private_topics:
@@ -119,6 +131,7 @@ en:
119
131
  btn_submit: :thredded.search.form.label
120
132
  label: Search
121
133
  placeholder: Search Topics and Posts
134
+ time_ago: "%{time} ago"
122
135
  topics:
123
136
  delete_confirm: Are you sure you want to delete this topic? This CANNOT be undone.
124
137
  delete_topic: Delete Topic
@@ -4,17 +4,23 @@ pt-BR:
4
4
  content_moderation_states:
5
5
  content_blocked_notice: Bloqueado
6
6
  content_blocked_notice_with_record_html: Bloqueados por %{moderator} %{time_ago}
7
+ email_notifier:
8
+ by_email: de e-mail
7
9
  errors:
8
10
  login_required: Por favor, autentique-se primeiro.
9
11
  not_authorized: Você não está autorizado a acessar esta página.
10
12
  private_topic_create_denied: Você não está autorizado a criar tópicos privados.
11
13
  private_topic_not_found: Este tópico privado não existe.
12
14
  form:
15
+ create_btn_submitting: Criando...
13
16
  update: Atualizar
17
+ update_btn_submitting: Atualizando...
14
18
  messageboard:
15
19
  create: Criar um novo Fórum de Mensagem
16
20
  form:
21
+ create_btn_submitting: :thredded.form.create_btn_submitting
17
22
  no_group: Sem Grupo
23
+ update_btn_submitting: :thredded.form.update_btn_submitting
18
24
  index:
19
25
  page_title: Fóruns de Mensagens
20
26
  last_updated_by_html: Atualizado %{time_ago} <cite>por %{user}</cite>
@@ -23,6 +29,8 @@ pt-BR:
23
29
  updated_notice: Fórum de mensagem foi atualizado
24
30
  messageboard_group:
25
31
  create: Criar um novo grupo de mensagens
32
+ form:
33
+ create_btn_submitting: :thredded.form.create_btn_submitting
26
34
  saved: Groupo de mensagens %{name} salvou
27
35
  moderation:
28
36
  approve_btn: Aprovar
@@ -65,7 +73,9 @@ pt-BR:
65
73
  form:
66
74
  content_label: Conteúdo
67
75
  create_btn: Enviar Resposta
76
+ create_btn_submitting: Postando...
68
77
  update_btn: Atualizar Post
78
+ update_btn_submitting: :thredded.form.update_btn_submitting
69
79
  pending_moderation_notice: O envio da mensagem será publicada quando foi revisado por um moderador.
70
80
  preferences:
71
81
  edit:
@@ -76,30 +86,29 @@ pt-BR:
76
86
  Quando alguém mencionar você através do seu usuário (ex.: @sam) você irá receber um e-mail com o conteúdo
77
87
  deste post.
78
88
  label: Siga os tópicos que são mencionados na
79
- followed_topic_emails:
80
- hint: Quando há um post em um tópico que você siga, você receberá um e-mail.
81
- label: Notificações de e-mail para tópicos seguido
82
89
  global_preferences_label: Configurações Globais
83
90
  messageboard_follow_topics_on_mention:
84
91
  hint: >-
85
92
  Quando alguém mencionar você através do seu usuário (ex.: @sam) neste fórum de mensagens, você irá receber
86
93
  um e-mail com o conteúdo deste post.
87
94
  label: :thredded.preferences.form.follow_topics_on_mention.label
88
- messageboard_followed_topic_emails:
89
- hint: Quando há um post em um tópico que você siga nesta messageboard será enviado um e-mail.
90
- label: Notificações de e-mail para tópicos seguido
95
+ messageboard_notifications_for_followed_topics:
96
+ label: :thredded.preferences.form.notifications_for_followed_topics.label
91
97
  messageboard_preferences_label_html: Configurações de Notificação para <em>%{messageboard}</em>
92
- notify_on_message:
93
- hint: Quando você for adicionado a uma conversa privada, você receberá um e-mail com o conteúdo desta
94
- conversa.
95
- label: E-mail notificações de mensagens privadas
98
+ notifications_for_followed_topics:
99
+ label: Notificações para tópicos seguido
100
+ notifications_for_private_topics:
101
+ label: Notificações de mensagens privadas
96
102
  submit_btn: Atualizar Configurações
97
103
  title: Configurações
104
+ update_btn_submitting: :thredded.form.update_btn_submitting
98
105
  updated_notice: Suas configurações foram atualizadas.
99
106
  private_posts:
100
107
  form:
101
108
  content_label: Mensagem
102
109
  create_btn: Enviar Mensagem
110
+ create_btn_submitting: Enviando...
111
+ update_btn_submitting: :thredded.form.update_btn_submitting
103
112
  private_topics:
104
113
  edit: Editar
105
114
  errors:
@@ -107,10 +116,12 @@ pt-BR:
107
116
  form:
108
117
  content_label: :thredded.private_posts.form.content_label
109
118
  create_btn: :thredded.private_posts.form.create_btn
119
+ create_btn_submitting: :thredded.private_posts.form.create_btn_submitting
110
120
  title_label: :thredded.topics.form.title_label
111
121
  title_placeholder_new: Escreva o assunto desta conversa
112
122
  title_placeholder_start: Iniciar uma nova conversa
113
123
  update_btn: Atualizar
124
+ update_btn_submitting: :thredded.private_posts.form.update_btn_submitting
114
125
  users_label: Participantes
115
126
  users_placeholder: Selecione usuários para participar desta conversa
116
127
  no_private_topics:
@@ -123,6 +134,7 @@ pt-BR:
123
134
  btn_submit: :thredded.search.form.label
124
135
  label: Buscar
125
136
  placeholder: Buscar Tópicos e Posts
137
+ time_ago: há %{time}
126
138
  topics:
127
139
  delete_confirm: Você tem certeza que deseja remover este tópico? Isto não pode ser desfeito.
128
140
  delete_topic: Remover Tópico
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Thredded::Engine.routes.draw do
2
+ Thredded::Engine.routes.draw do # rubocop:disable Metrics/BlockLength
3
3
  resource :theme_preview, only: [:show], path: 'theme-preview' if %w(development test).include? Rails.env
4
4
 
5
5
  positive_int = /[1-9]\d*/
@@ -161,8 +161,6 @@ class CreateThredded < ActiveRecord::Migration
161
161
  create_table :thredded_user_preferences do |t|
162
162
  t.references :user, null: false
163
163
  t.boolean :follow_topics_on_mention, default: true, null: false
164
- t.boolean :notify_on_message, default: true, null: false
165
- t.boolean :followed_topic_emails, default: true, null: false
166
164
  t.timestamps null: false
167
165
  t.index [:user_id], name: :index_thredded_user_preferences_on_user_id
168
166
  end
@@ -171,7 +169,6 @@ class CreateThredded < ActiveRecord::Migration
171
169
  t.references :user, null: false
172
170
  t.references :messageboard, null: false
173
171
  t.boolean :follow_topics_on_mention, default: true, null: false
174
- t.boolean :followed_topic_emails, default: true, null: false
175
172
  t.timestamps null: false
176
173
  t.index [:user_id, :messageboard_id],
177
174
  name: :thredded_user_messageboard_preferences_user_id_messageboard_id,
@@ -217,6 +214,29 @@ class CreateThredded < ActiveRecord::Migration
217
214
  order: { created_at: :desc },
218
215
  name: :index_thredded_moderation_records_for_display
219
216
  end
217
+
218
+ create_table :thredded_notifications_for_private_topics do |t|
219
+ t.integer :user_id, null: false
220
+ t.string :notifier_key, null: false
221
+ t.boolean :enabled, default: true, null: false
222
+ t.index [:user_id, :notifier_key],
223
+ name: 'thredded_notifications_for_private_topics_unique', unique: true
224
+ end
225
+ create_table :thredded_notifications_for_followed_topics do |t|
226
+ t.integer :user_id, null: false
227
+ t.string :notifier_key, null: false
228
+ t.boolean :enabled, default: true, null: false
229
+ t.index [:user_id, :notifier_key],
230
+ name: 'thredded_notifications_for_followed_topics_unique', unique: true
231
+ end
232
+ create_table :thredded_messageboard_notifications_for_followed_topics do |t|
233
+ t.integer :user_id, null: false
234
+ t.integer :messageboard_id, null: false
235
+ t.string :notifier_key, null: false
236
+ t.boolean :enabled, default: true, null: false
237
+ t.index [:user_id, :messageboard_id, :notifier_key],
238
+ name: 'thredded_messageboard_notifications_for_followed_topics_unique', unique: true
239
+ end
220
240
  end
221
241
  end
222
242
  # rubocop:enable Metrics/MethodLength
@@ -6,7 +6,7 @@ class UpgradeV02ToV03 < ActiveRecord::Migration
6
6
  remove_index :thredded_notification_preferences, name: :index_thredded_notification_preferences_on_messageboard_id
7
7
  remove_index :thredded_notification_preferences, name: :index_thredded_notification_preferences_on_user_id
8
8
  rename_table :thredded_notification_preferences, :thredded_user_messageboard_preferences
9
- remove_column :thredded_user_messageboard_preferences, :notify_on_message
9
+ remove_column :thredded_user_messageboard_preferences, :notifications_for_private_topics
10
10
  change_column_null :thredded_user_messageboard_preferences, :notify_on_mention, false
11
11
  add_column :thredded_user_preferences, :notify_on_mention, :boolean, default: true, null: false
12
12
  add_column :thredded_user_preferences, :notify_on_message, :boolean, default: true, null: false
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ # rubocop:disable Metrics/MethodLength
3
+ class UpgradeV08ToV09 < ActiveRecord::Migration
4
+ def up
5
+ create_table :thredded_notifications_for_private_topics do |t|
6
+ t.integer :user_id, null: false
7
+ t.string :notifier_key, null: false
8
+ t.boolean :enabled, default: true, null: false
9
+ t.index [:user_id, :notifier_key],
10
+ name: 'thredded_notifications_for_private_topics_unique', unique: true
11
+ end
12
+ create_table :thredded_notifications_for_followed_topics do |t|
13
+ t.integer :user_id, null: false
14
+ t.string :notifier_key, null: false
15
+ t.boolean :enabled, default: true, null: false
16
+ t.index [:user_id, :notifier_key],
17
+ name: 'thredded_notifications_for_followed_topics_unique', unique: true
18
+ end
19
+ create_table :thredded_messageboard_notifications_for_followed_topics do |t|
20
+ t.integer :user_id, null: false
21
+ t.integer :messageboard_id, null: false
22
+ t.string :notifier_key, null: false
23
+ t.boolean :enabled, default: true, null: false
24
+ t.index [:user_id, :messageboard_id, :notifier_key],
25
+ name: 'thredded_messageboard_notifications_for_followed_topics_unique', unique: true
26
+ end
27
+
28
+ Thredded::UserPreference.includes(:user).each do |pref|
29
+ pref.notifications_for_private_topics.create(notifier_key: 'email', enabled: pref.notify_on_message)
30
+ pref.notifications_for_followed_topics.create(notifier_key: 'email', enabled: pref.followed_topic_emails)
31
+ end
32
+ Thredded::UserMessageboardPreference.includes(:user).each do |pref|
33
+ Thredded::MessageboardNotificationsForFollowedTopics.create(
34
+ user_id: pref.user_id,
35
+ messageboard_id: pref.messageboard_id,
36
+ notifier_key: 'email',
37
+ enabled: pref.followed_topic_emails
38
+ )
39
+ end
40
+
41
+ remove_column :thredded_user_preferences, :notify_on_message
42
+ remove_column :thredded_user_preferences, :followed_topic_emails
43
+ remove_column :thredded_user_messageboard_preferences, :followed_topic_emails
44
+ end
45
+
46
+ def down
47
+ add_column :thredded_user_preferences, :notify_on_message, :boolean, default: true, null: false
48
+ add_column :thredded_user_preferences, :followed_topic_emails, :boolean, default: true, null: false
49
+ add_column :thredded_user_messageboard_preferences, :followed_topic_emails, :boolean, default: true, null: false
50
+
51
+ drop_table :thredded_messageboard_notifications_for_followed_topics
52
+ drop_table :thredded_notifications_for_followed_topics
53
+ drop_table :thredded_notifications_for_private_topics
54
+ end
55
+ end
56
+ # rubocop:enable Metrics/MethodLength