thredded 0.13.0 → 0.14.0
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.
- checksums.yaml +4 -4
- data/README.md +29 -25
- data/app/assets/images/thredded/lock.svg +1 -0
- data/app/assets/javascripts/thredded/components/mention_autocompletion.es6 +2 -1
- data/app/assets/javascripts/thredded/components/post_form.es6 +1 -1
- data/app/assets/javascripts/thredded/components/time_stamps.es6 +1 -1
- data/app/assets/javascripts/thredded/components/topic_form.es6 +1 -1
- data/app/assets/javascripts/thredded/components/users_select.es6 +1 -1
- data/app/assets/javascripts/thredded/dependencies/autosize.js +1 -0
- data/app/assets/javascripts/thredded/dependencies.js +1 -1
- data/app/assets/stylesheets/thredded/base/_variables.scss +4 -0
- data/app/assets/stylesheets/thredded/components/_form-list.scss +2 -1
- data/app/assets/stylesheets/thredded/components/_messageboard.scss +10 -1
- data/app/assets/stylesheets/thredded/components/_onebox.scss +0 -9
- data/app/assets/stylesheets/thredded/components/_post.scss +7 -1
- data/app/assets/stylesheets/thredded/components/_topics.scss +12 -0
- data/app/commands/thredded/create_messageboard.rb +3 -3
- data/app/commands/thredded/mark_all_read.rb +1 -1
- data/app/commands/thredded/notify_following_users.rb +40 -22
- data/app/commands/thredded/notify_private_topic_users.rb +1 -1
- data/app/controllers/concerns/thredded/new_post_params.rb +1 -1
- data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -1
- data/app/controllers/thredded/application_controller.rb +1 -1
- data/app/controllers/thredded/autocomplete_users_controller.rb +1 -1
- data/app/controllers/thredded/messageboard_groups_controller.rb +2 -2
- data/app/controllers/thredded/messageboards_controller.rb +7 -7
- data/app/controllers/thredded/moderation_controller.rb +1 -1
- data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/post_previews_controller.rb +3 -3
- data/app/controllers/thredded/posts_controller.rb +9 -5
- data/app/controllers/thredded/preferences_controller.rb +2 -2
- data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
- data/app/controllers/thredded/private_post_previews_controller.rb +3 -3
- data/app/controllers/thredded/private_posts_controller.rb +5 -5
- data/app/controllers/thredded/private_topic_previews_controller.rb +1 -1
- data/app/controllers/thredded/read_states_controller.rb +1 -1
- data/app/controllers/thredded/theme_previews_controller.rb +23 -23
- data/app/controllers/thredded/topic_previews_controller.rb +1 -1
- data/app/forms/thredded/private_topic_form.rb +1 -1
- data/app/forms/thredded/topic_form.rb +2 -2
- data/app/forms/thredded/user_preferences_form.rb +2 -2
- data/app/helpers/thredded/render_helper.rb +1 -1
- data/app/jobs/thredded/auto_follow_and_notify_job.rb +3 -3
- data/app/mailer_previews/thredded/base_mailer_preview.rb +5 -5
- data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +1 -5
- data/app/mailers/thredded/post_mailer.rb +11 -6
- data/app/mailers/thredded/private_topic_mailer.rb +12 -8
- data/app/models/concerns/thredded/content_moderation_state.rb +1 -1
- data/app/models/thredded/topic.rb +1 -1
- data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +0 -11
- data/app/models/thredded/user_permissions/moderate/none.rb +0 -11
- data/app/models/thredded/user_permissions/write/all.rb +0 -11
- data/app/models/thredded/user_permissions/write/none.rb +0 -11
- data/app/models/thredded/user_topic_follow.rb +4 -2
- data/app/notifiers/thredded/email_notifier.rb +6 -2
- data/app/policies/thredded/messageboard_policy.rb +3 -1
- data/app/policies/thredded/post_policy.rb +5 -1
- data/app/view_models/thredded/private_topic_view.rb +1 -1
- data/app/view_models/thredded/topic_email_view.rb +0 -4
- data/app/views/thredded/messageboards/_form.html.erb +6 -0
- data/app/views/thredded/messageboards/_messageboard.html.erb +1 -5
- data/app/views/thredded/messageboards/_messageboard_meta.html.erb +13 -0
- data/app/views/thredded/moderation/users.html.erb +2 -2
- data/app/views/thredded/post_mailer/post_notification.html.erb +9 -6
- data/app/views/thredded/post_mailer/post_notification.text.erb +9 -5
- data/app/views/thredded/preferences/_form.html.erb +9 -9
- data/app/views/thredded/private_topic_mailer/message_notification.html.erb +10 -4
- data/app/views/thredded/private_topic_mailer/message_notification.text.erb +11 -8
- data/app/views/thredded/private_topics/new.html.erb +1 -1
- data/app/views/thredded/shared/nav/_standalone.html.erb +1 -1
- data/app/views/thredded/theme_previews/show.html.erb +6 -4
- data/app/views/thredded/topics/_topic.html.erb +2 -1
- data/app/views/thredded/topics/index.html.erb +6 -1
- data/app/views/thredded/topics/new.html.erb +1 -1
- data/app/views/thredded/topics/show.html.erb +4 -0
- data/config/locales/de.yml +249 -0
- data/config/locales/en.yml +43 -0
- data/config/locales/es.yml +45 -0
- data/config/locales/fr.yml +247 -0
- data/config/locales/pl.yml +43 -0
- data/config/locales/pt-BR.yml +45 -0
- data/config/locales/ru.yml +43 -1
- data/config/locales/zh-CN.yml +238 -0
- data/db/migrate/20160329231848_create_thredded.rb +3 -2
- data/db/upgrade_migrations/20170811090735_upgrade_thredded_v0_13_to_v_014.rb +21 -0
- data/lib/generators/thredded/install/templates/initializer.rb +3 -3
- data/lib/thredded/database_seeder.rb +12 -12
- data/lib/thredded/engine.rb +1 -1
- data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
- data/lib/thredded/version.rb +1 -1
- data/lib/thredded.rb +2 -1
- data/vendor/assets/javascripts/autosize.min.js +6 -0
- data/vendor/assets/javascripts/textcomplete.min.js +2 -1
- metadata +19 -12
- data/vendor/assets/javascripts/autosize.js +0 -290
- /data/{app/notifiers → lib}/thredded/base_notifier.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ca544efca243747b5f8b3d11c65c5376999c016
|
|
4
|
+
data.tar.gz: 6d08bb441e304681531bee3977d32d66e9854f60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1601695337ccb89d4c2f2b058f183d22ae33eef5381c1165a3368ef93ab72915f232224a9d8c394c9c8cbeac46931b01be9be3c9af556731b8fe0fa2469381c
|
|
7
|
+
data.tar.gz: c25c917fed02ad08cd38e88dad77990c76f21165d04a7c684efe8431c5bb12b8d1ed37742550268dd16a3e8795a41c28e0d9f5af98451ac9dd6bbdbff172bfc0
|
data/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Then, see the rest of this Readme for more information about using and customizi
|
|
|
98
98
|
Add the gem to your Gemfile:
|
|
99
99
|
|
|
100
100
|
```ruby
|
|
101
|
-
gem 'thredded', '~> 0.
|
|
101
|
+
gem 'thredded', '~> 0.14.0'
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
Add the Thredded [initializer] to your parent app by running the install generator.
|
|
@@ -229,7 +229,9 @@ Include thredded JavaScripts in your `application.js`:
|
|
|
229
229
|
|
|
230
230
|
Thredded is fully compatible with deferred and async script loading.
|
|
231
231
|
|
|
232
|
-
#####
|
|
232
|
+
##### Alternative JavaScript dependencies
|
|
233
|
+
|
|
234
|
+
<details><summary><b>Rails UJS version</b></summary>
|
|
233
235
|
|
|
234
236
|
By default, thredded loads `rails-ujs`. If you're using Rails before v5.1, you need to add `rails-ujs` to
|
|
235
237
|
your Gemfile.
|
|
@@ -240,8 +242,9 @@ If you'd like it to use `jquery_ujs` instead, run this command from your app dir
|
|
|
240
242
|
mkdir -p app/assets/javascripts/thredded/dependencies/
|
|
241
243
|
printf '//= require jquery3\n//= require jquery_ujs\n' > app/assets/javascripts/thredded/dependencies/ujs.js
|
|
242
244
|
```
|
|
245
|
+
</details>
|
|
243
246
|
|
|
244
|
-
|
|
247
|
+
<details><summary><b>Timeago version</b></summary>
|
|
245
248
|
|
|
246
249
|
By default, thredded loads `timeago.js`.
|
|
247
250
|
|
|
@@ -261,6 +264,7 @@ E.g. for Brazilian Portuguese with jquery.timeago:
|
|
|
261
264
|
//= require locales/jquery.timeago.pt-br
|
|
262
265
|
//= require thredded/thredded
|
|
263
266
|
```
|
|
267
|
+
</details>
|
|
264
268
|
|
|
265
269
|
#### Thredded page title and ID
|
|
266
270
|
|
|
@@ -376,8 +380,8 @@ change_column_default :thredded_user_preferences, :auto_follow_topics, 1
|
|
|
376
380
|
|
|
377
381
|
## I18n
|
|
378
382
|
|
|
379
|
-
Thredded is mostly internationalized. It is currently available in English, Brazilian Portuguese,
|
|
380
|
-
and Spanish.
|
|
383
|
+
Thredded is mostly internationalized. It is currently available in English, Brazilian Portuguese, Chinese (Simplified),
|
|
384
|
+
German, Polish, Russian, French, and Spanish.
|
|
381
385
|
We welcome PRs adding support for new languages.
|
|
382
386
|
|
|
383
387
|
Here are the steps to ensure the best support for your language if it isn't English:
|
|
@@ -387,9 +391,13 @@ Here are the steps to ensure the best support for your language if it isn't Engl
|
|
|
387
391
|
2. Require the translations for timeago.js in your JavaScript. E.g. for Brazilian Portuguese:
|
|
388
392
|
|
|
389
393
|
```js
|
|
394
|
+
//= require thredded/dependencies/timeago
|
|
390
395
|
//= require timeago/locales/pt_BR
|
|
396
|
+
//= require thredded
|
|
391
397
|
```
|
|
392
398
|
|
|
399
|
+
Note that it is important that timeago and its locales are required *before* `//= require thredded`.
|
|
400
|
+
|
|
393
401
|
3. To generate URL slugs for messageboards, categories, and topics with support for more language than English,
|
|
394
402
|
you can use a gem like [babosa](https://github.com/norman/babosa).
|
|
395
403
|
Add babosa to your Gemfile and uncomment the `Thredded.slugifier` proc for babosa in the initializer.
|
|
@@ -425,21 +433,13 @@ The methods used by Thredded for determining the permissions are described below
|
|
|
425
433
|
|
|
426
434
|
#### Posting to messageboards
|
|
427
435
|
|
|
428
|
-
|
|
436
|
+
A list of messageboards that a given user can post in.
|
|
429
437
|
|
|
430
438
|
```ruby
|
|
431
439
|
# @return [ActiveRecord::Relation<Thredded::Messageboard>] messageboards that the user can post in
|
|
432
440
|
thredded_can_write_messageboards
|
|
433
441
|
```
|
|
434
442
|
|
|
435
|
-
2. A list of users that can post to a given list of messageboards.
|
|
436
|
-
|
|
437
|
-
```ruby
|
|
438
|
-
# @param messageboards [Array<Thredded::Messageboard>]
|
|
439
|
-
# @return [ActiveRecord::Relation<User>] users that can post to the given messageboards
|
|
440
|
-
self.thredded_messageboards_writers(messageboards)
|
|
441
|
-
```
|
|
442
|
-
|
|
443
443
|
#### Messaging other users (posting to private topics)
|
|
444
444
|
|
|
445
445
|
A list of users a given user can message:
|
|
@@ -451,19 +451,12 @@ thredded_can_message_users
|
|
|
451
451
|
|
|
452
452
|
#### Moderating messageboards
|
|
453
453
|
|
|
454
|
-
|
|
454
|
+
A list of messageboards that a given user can moderate:
|
|
455
455
|
|
|
456
456
|
```ruby
|
|
457
457
|
# @return [ActiveRecord::Relation<Thredded::Messageboard>] messageboards that the user can moderate
|
|
458
458
|
thredded_can_moderate_messageboards
|
|
459
459
|
```
|
|
460
|
-
2. A list of users that can moderate a given list of messageboards:
|
|
461
|
-
|
|
462
|
-
```ruby
|
|
463
|
-
# @param messageboards [Array<Thredded::Messageboard>]
|
|
464
|
-
# @return [ActiveRecord::Relation<User>] users that can moderate the given messageboards
|
|
465
|
-
self.thredded_messageboards_moderators(messageboards)
|
|
466
|
-
```
|
|
467
460
|
|
|
468
461
|
#### Admin permissions
|
|
469
462
|
|
|
@@ -603,9 +596,20 @@ run tasks that maintain the test database.
|
|
|
603
596
|
By default, SQLite is used in development and test. On Travis, the tests will run using SQLite, PostgreSQL, MySQL,
|
|
604
597
|
and all the supported Rails versions.
|
|
605
598
|
|
|
606
|
-
The test suite requires
|
|
607
|
-
|
|
608
|
-
|
|
599
|
+
The test suite requires Chromium v59+ and its WebDriver installed:
|
|
600
|
+
|
|
601
|
+
On Ubuntu, run:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
sudo apt-get install chromium-chromedriver
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
On Mac, run:
|
|
608
|
+
|
|
609
|
+
```bash
|
|
610
|
+
brew cask install chromium
|
|
611
|
+
brew install chromedriver
|
|
612
|
+
```
|
|
609
613
|
|
|
610
614
|
### Ruby
|
|
611
615
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10 16c0-1.104.896-2 2-2s2 .896 2 2c0 .738-.404 1.376-1 1.723v2.277h-2v-2.277c-.596-.347-1-.985-1-1.723zm11-6v14h-18v-14h3v-4c0-3.313 2.687-6 6-6s6 2.687 6 6v4h3zm-13 0h8v-4c0-2.206-1.795-4-4-4s-4 1.794-4 4v4zm11 2h-14v10h14v-10z"/></svg>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//= require thredded/components/user_textcomplete
|
|
2
2
|
|
|
3
3
|
const ThreddedMentionAutocompletion = {
|
|
4
|
-
MATCH_RE: /(^@|\s@)"?([\w
|
|
4
|
+
MATCH_RE: /(^@|\s@)"?([\w., \-()]+[\w.,\-()])$/,
|
|
5
|
+
// the last letter has to not be a space so it doesn't match after replacement
|
|
5
6
|
DROPDOWN_MAX_COUNT: 6,
|
|
6
7
|
|
|
7
8
|
init(form, textarea) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
if (!threddedContainer) return;
|
|
9
9
|
timeago().render(
|
|
10
10
|
document.querySelectorAll(COMPONENT_SELECTOR),
|
|
11
|
-
threddedContainer.getAttribute('data-thredded-locale'));
|
|
11
|
+
threddedContainer.getAttribute('data-thredded-locale').replace('-', '_'));
|
|
12
12
|
});
|
|
13
13
|
document.addEventListener('turbolinks:before-cache', () => {
|
|
14
14
|
timeago.cancel();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= require autosize.min
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//= require thredded/dependencies/timeago
|
|
2
2
|
//= require thredded/dependencies/ujs
|
|
3
|
-
//= require autosize
|
|
3
|
+
//= require thredded/dependencies/autosize
|
|
4
4
|
//= require thredded/dependencies/textcomplete
|
|
5
5
|
|
|
6
6
|
// We are not currently using any features that require the Babel polyfill
|
|
@@ -91,6 +91,10 @@ $thredded-badge-active-background: $thredded-action-color !default;
|
|
|
91
91
|
$thredded-badge-inactive-color: $thredded-button-color !default;
|
|
92
92
|
$thredded-badge-inactive-background: rgba($thredded-text-color, 0.3) !default;
|
|
93
93
|
|
|
94
|
+
// Locked topics
|
|
95
|
+
$thredded-badge-locked-color: $thredded-alert-warning-background;
|
|
96
|
+
$thredded-badge-locked-background: $thredded-alert-warning-color;
|
|
97
|
+
|
|
94
98
|
// Onebox
|
|
95
99
|
$thredded-onebox-favicons: (
|
|
96
100
|
'amazon': 'favicons/amazon.png',
|
|
@@ -49,11 +49,20 @@
|
|
|
49
49
|
font-size: 0.875em;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.thredded--messageboard--meta {
|
|
52
|
+
.thredded--messageboard--meta--icon {
|
|
53
|
+
@extend %thredded--icon;
|
|
54
|
+
opacity: 0.8;
|
|
55
|
+
width: 1rem;
|
|
56
|
+
height: 1rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.thredded--messageboard--meta--counts {
|
|
53
60
|
@extend %thredded--heading;
|
|
54
61
|
color: $thredded-secondary-text-color;
|
|
55
62
|
display: inline-block;
|
|
63
|
+
font-size: inherit;
|
|
56
64
|
font-weight: normal;
|
|
65
|
+
margin-bottom: 0;
|
|
57
66
|
vertical-align: baseline;
|
|
58
67
|
}
|
|
59
68
|
|
|
@@ -195,15 +195,6 @@ pre.onebox code {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
// Onebox - Google Maps
|
|
199
|
-
.maps-onebox {
|
|
200
|
-
// The onebox gem adds a div with inline styles that breaks mobile
|
|
201
|
-
// Hide the div
|
|
202
|
-
> div:first-child {
|
|
203
|
-
display: none;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
198
|
// Onebox - Twitter - Status
|
|
208
199
|
aside.onebox.twitterstatus .onebox-body {
|
|
209
200
|
h4 {
|
|
@@ -49,13 +49,19 @@
|
|
|
49
49
|
vertical-align: baseline;
|
|
50
50
|
width: 1.75rem; // 28px
|
|
51
51
|
|
|
52
|
-
@
|
|
52
|
+
@media (min-width: $thredded-grid-container-max-width + $thredded-content-breakout-min-width + 0.00001rem) {
|
|
53
53
|
height: 2.25rem; // 36px
|
|
54
54
|
left: -3rem;
|
|
55
55
|
position: absolute;
|
|
56
56
|
top: -0.5rem;
|
|
57
57
|
width: 2.25rem; // 36px
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
@media (min-width: $thredded-grid-container-max-width + $thredded-content-breakout-min-width + 9.5rem + 0.00001rem) {
|
|
61
|
+
height: 3.25rem;
|
|
62
|
+
left: -4.125rem;
|
|
63
|
+
width: 3.25rem;
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
.thredded--post--topic {
|
|
@@ -172,3 +172,15 @@
|
|
|
172
172
|
display: none;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
.thredded--topic-locked {
|
|
177
|
+
.thredded--topics--posts-count {
|
|
178
|
+
color: $thredded-badge-locked-color;
|
|
179
|
+
background-color: $thredded-badge-locked-background;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.thredded--topic--locked-notice {
|
|
184
|
+
@extend %thredded--alert;
|
|
185
|
+
@extend %thredded--alert--warning;
|
|
186
|
+
}
|
|
@@ -12,14 +12,14 @@ module Thredded
|
|
|
12
12
|
|
|
13
13
|
# @return [boolean] true if the messageboard was created and seeded with a topic successfully.
|
|
14
14
|
def run
|
|
15
|
-
Messageboard.transaction do
|
|
15
|
+
Thredded::Messageboard.transaction do
|
|
16
16
|
fail ActiveRecord::Rollback unless @messageboard.save
|
|
17
|
-
topic = Topic.create!(
|
|
17
|
+
topic = Thredded::Topic.create!(
|
|
18
18
|
messageboard: @messageboard,
|
|
19
19
|
user: @user,
|
|
20
20
|
title: first_topic_title
|
|
21
21
|
)
|
|
22
|
-
Post.create!(
|
|
22
|
+
Thredded::Post.create!(
|
|
23
23
|
messageboard: @messageboard,
|
|
24
24
|
user: @user,
|
|
25
25
|
postable: topic,
|
|
@@ -9,50 +9,68 @@ module Thredded
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def run
|
|
12
|
+
subscribed_users.select! do |user|
|
|
13
|
+
# Record idempotently that the notification happened.
|
|
14
|
+
# If a notification was already created (e.g. from another thread/process),
|
|
15
|
+
# this will return false due to the unique constraint on the table
|
|
16
|
+
# and the user will be excluded.
|
|
17
|
+
subscribed_via_any_notifier?(user) && record_as_notified_successful?(user)
|
|
18
|
+
end
|
|
12
19
|
Thredded.notifiers.each do |notifier|
|
|
13
20
|
notifiable_users = targeted_users(notifier)
|
|
14
|
-
notifiable_users = notifiable_users.select do |user|
|
|
15
|
-
# Create a notification for the user.
|
|
16
|
-
# If a notification was already created (from another thread/process),
|
|
17
|
-
# this will return false due to the unique constraint on the table
|
|
18
|
-
# and the user will be excluded.
|
|
19
|
-
Thredded::UserPostNotification.create_from_post_and_user(@post, user)
|
|
20
|
-
end
|
|
21
21
|
next if notifiable_users.empty?
|
|
22
22
|
notifier.new_post(@post, notifiable_users)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def targeted_users(notifier)
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
subscribed_users.select do |user|
|
|
28
|
+
user_subscribed_via?(user, notifier)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.detect_or_default(messageboard_notifier_prefs_by_user_id[user.id], notifier).enabled?
|
|
38
|
-
end
|
|
32
|
+
def user_subscribed_via?(user, notifier)
|
|
33
|
+
Thredded::NotificationsForFollowedTopics
|
|
34
|
+
.detect_or_default(user.thredded_notifications_for_followed_topics, notifier).enabled? &&
|
|
35
|
+
Thredded::MessageboardNotificationsForFollowedTopics
|
|
36
|
+
.detect_or_default(messageboard_notifier_prefs_by_user_id[user.id], notifier).enabled?
|
|
39
37
|
end
|
|
40
38
|
|
|
39
|
+
# @return [Array<User>]
|
|
41
40
|
def subscribed_users
|
|
42
41
|
@subscribed_users ||=
|
|
43
|
-
@post.postable.followers.includes(:thredded_notifications_for_followed_topics).
|
|
44
|
-
user
|
|
42
|
+
@post.postable.followers.includes(:thredded_notifications_for_followed_topics).select do |user|
|
|
43
|
+
!already_notified?(user) && !originator?(user) && can_read_post?(user)
|
|
45
44
|
end
|
|
46
45
|
end
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def originator?(user)
|
|
50
|
+
user == @post.user
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
def can_read_post?(user)
|
|
54
|
+
Thredded::PostPolicy.new(user, @post).read?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def already_notified?(user)
|
|
58
|
+
# We memoize the set so that records created during this task do not affect the result,
|
|
59
|
+
# so that a user can receive notifications via multiple notifiers.
|
|
60
|
+
@already_notified_user_ids ||= Set.new Thredded::UserPostNotification.notified_user_ids(@post)
|
|
61
|
+
@already_notified_user_ids.include?(user.id)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def subscribed_via_any_notifier?(user)
|
|
65
|
+
Thredded.notifiers.any? { |notifier| user_subscribed_via?(user, notifier) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def record_as_notified_successful?(user)
|
|
69
|
+
Thredded::UserPostNotification.create_from_post_and_user(@post, user)
|
|
70
|
+
end
|
|
53
71
|
|
|
54
72
|
def messageboard_notifier_prefs_by_user_id
|
|
55
|
-
@messageboard_notifier_prefs_by_user_id ||= MessageboardNotificationsForFollowedTopics
|
|
73
|
+
@messageboard_notifier_prefs_by_user_id ||= Thredded::MessageboardNotificationsForFollowedTopics
|
|
56
74
|
.where(user_id: subscribed_users.map(&:id))
|
|
57
75
|
.for_messageboard(@post.messageboard).group_by(&:user_id)
|
|
58
76
|
end
|
|
@@ -26,7 +26,7 @@ module Thredded
|
|
|
26
26
|
|
|
27
27
|
def only_those_with_this_notifier_enabled(users, notifier)
|
|
28
28
|
users.select do |user|
|
|
29
|
-
NotificationsForPrivateTopics
|
|
29
|
+
Thredded::NotificationsForPrivateTopics
|
|
30
30
|
.detect_or_default(user.thredded_notifications_for_private_topics, notifier).enabled?
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -11,7 +11,7 @@ module Thredded
|
|
|
11
11
|
.merge(ip: request.remote_ip).tap do |p|
|
|
12
12
|
quote_id = p.delete(:quote_private_post_id)
|
|
13
13
|
if quote_id
|
|
14
|
-
post = PrivatePost.find(quote_id)
|
|
14
|
+
post = Thredded::PrivatePost.find(quote_id)
|
|
15
15
|
authorize_reading post
|
|
16
16
|
p[:quote_post] = post
|
|
17
17
|
end
|
|
@@ -105,7 +105,7 @@ module Thredded
|
|
|
105
105
|
# @return [Thredded::Messageboard]
|
|
106
106
|
# @raise [Thredded::Errors::MessageboardNotFound] if the messageboard with the given slug does not exist.
|
|
107
107
|
def messageboard
|
|
108
|
-
@messageboard ||= Messageboard.friendly_find!(params[:messageboard_id])
|
|
108
|
+
@messageboard ||= Thredded::Messageboard.friendly_find!(params[:messageboard_id])
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def messageboard_or_nil
|
|
@@ -5,7 +5,7 @@ module Thredded
|
|
|
5
5
|
MAX_RESULTS = 20
|
|
6
6
|
|
|
7
7
|
def index
|
|
8
|
-
authorize_creating PrivateTopicForm.new(user: thredded_current_user).private_topic
|
|
8
|
+
authorize_creating Thredded::PrivateTopicForm.new(user: thredded_current_user).private_topic
|
|
9
9
|
users = params.key?(:q) ? users_by_prefix : users_by_ids
|
|
10
10
|
render json: {
|
|
11
11
|
results: users.map do |user|
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
module Thredded
|
|
4
4
|
class MessageboardGroupsController < Thredded::ApplicationController
|
|
5
5
|
def new
|
|
6
|
-
@messageboard_group = MessageboardGroup.new
|
|
6
|
+
@messageboard_group = Thredded::MessageboardGroup.new
|
|
7
7
|
authorize @messageboard_group, :create?
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def create
|
|
11
|
-
@messageboard_group = MessageboardGroup.new(messageboard_group_params)
|
|
11
|
+
@messageboard_group = Thredded::MessageboardGroup.new(messageboard_group_params)
|
|
12
12
|
authorize @messageboard_group, :create?
|
|
13
13
|
|
|
14
14
|
if @messageboard_group.save
|
|
@@ -8,17 +8,17 @@ module Thredded
|
|
|
8
8
|
after_action :verify_policy_scoped, except: %i[new create edit update]
|
|
9
9
|
|
|
10
10
|
def index
|
|
11
|
-
@groups = MessageboardGroupView.grouped(policy_scope(Messageboard.all))
|
|
11
|
+
@groups = Thredded::MessageboardGroupView.grouped(policy_scope(Thredded::Messageboard.all))
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def new
|
|
15
|
-
@messageboard = Messageboard.new
|
|
16
|
-
@messageboard_group = MessageboardGroup.all
|
|
15
|
+
@messageboard = Thredded::Messageboard.new
|
|
16
|
+
@messageboard_group = Thredded::MessageboardGroup.all
|
|
17
17
|
authorize_creating @messageboard
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def create
|
|
21
|
-
@messageboard = Messageboard.new(messageboard_params)
|
|
21
|
+
@messageboard = Thredded::Messageboard.new(messageboard_params)
|
|
22
22
|
authorize_creating @messageboard
|
|
23
23
|
if Thredded::CreateMessageboard.new(@messageboard, thredded_current_user).run
|
|
24
24
|
redirect_to root_path
|
|
@@ -28,12 +28,12 @@ module Thredded
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def edit
|
|
31
|
-
@messageboard = Messageboard.friendly_find!(params[:id])
|
|
31
|
+
@messageboard = Thredded::Messageboard.friendly_find!(params[:id])
|
|
32
32
|
authorize @messageboard, :update?
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def update
|
|
36
|
-
@messageboard = Messageboard.friendly_find!(params[:id])
|
|
36
|
+
@messageboard = Thredded::Messageboard.friendly_find!(params[:id])
|
|
37
37
|
authorize @messageboard, :update?
|
|
38
38
|
if @messageboard.update(messageboard_params)
|
|
39
39
|
redirect_to messageboard_topics_path(@messageboard), notice: I18n.t('thredded.messageboard.updated_notice')
|
|
@@ -47,7 +47,7 @@ module Thredded
|
|
|
47
47
|
def messageboard_params
|
|
48
48
|
params
|
|
49
49
|
.require(:messageboard)
|
|
50
|
-
.permit(:name, :description, :messageboard_group_id)
|
|
50
|
+
.permit(:name, :description, :messageboard_group_id, :locked)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Thredded
|
|
4
4
|
class PostPermalinksController < Thredded::ApplicationController
|
|
5
5
|
def show
|
|
6
|
-
post = Post.find(params[:id])
|
|
6
|
+
post = Thredded::Post.find(params[:id])
|
|
7
7
|
authorize post, :read?
|
|
8
8
|
redirect_to post_url(post, user: thredded_current_user), status: :found
|
|
9
9
|
end
|
|
@@ -6,14 +6,14 @@ module Thredded
|
|
|
6
6
|
|
|
7
7
|
# Preview a new post
|
|
8
8
|
def preview
|
|
9
|
-
@post = Post.new(post_params)
|
|
10
|
-
@post.postable = Topic.friendly_find!(params[:topic_id])
|
|
9
|
+
@post = Thredded::Post.new(post_params)
|
|
10
|
+
@post.postable = Thredded::Topic.friendly_find!(params[:topic_id])
|
|
11
11
|
render_preview
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Preview an update to an existing post
|
|
15
15
|
def update
|
|
16
|
-
@post = Post.find(params[:post_id])
|
|
16
|
+
@post = Thredded::Post.find(params[:post_id])
|
|
17
17
|
@post.assign_attributes(post_params)
|
|
18
18
|
render_preview
|
|
19
19
|
end
|
|
@@ -12,12 +12,16 @@ module Thredded
|
|
|
12
12
|
after_action :verify_authorized
|
|
13
13
|
|
|
14
14
|
def new
|
|
15
|
-
@post_form = PostForm.new(
|
|
15
|
+
@post_form = Thredded::PostForm.new(
|
|
16
|
+
user: thredded_current_user, topic: parent_topic, post_params: new_post_params
|
|
17
|
+
)
|
|
16
18
|
authorize_creating @post_form.post
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def create
|
|
20
|
-
@post_form = PostForm.new(
|
|
22
|
+
@post_form = Thredded::PostForm.new(
|
|
23
|
+
user: thredded_current_user, topic: parent_topic, post_params: new_post_params
|
|
24
|
+
)
|
|
21
25
|
authorize_creating @post_form.post
|
|
22
26
|
|
|
23
27
|
if @post_form.save
|
|
@@ -28,7 +32,7 @@ module Thredded
|
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def edit
|
|
31
|
-
@post_form = PostForm.for_persisted(post)
|
|
35
|
+
@post_form = Thredded::PostForm.for_persisted(post)
|
|
32
36
|
authorize @post_form.post, :update?
|
|
33
37
|
return redirect_to(canonical_topic_params) unless params_match?(canonical_topic_params)
|
|
34
38
|
render
|
|
@@ -36,7 +40,7 @@ module Thredded
|
|
|
36
40
|
|
|
37
41
|
def update
|
|
38
42
|
authorize post, :update?
|
|
39
|
-
post.
|
|
43
|
+
post.update(new_post_params)
|
|
40
44
|
|
|
41
45
|
redirect_to post_path(post, user: thredded_current_user)
|
|
42
46
|
end
|
|
@@ -76,7 +80,7 @@ module Thredded
|
|
|
76
80
|
end
|
|
77
81
|
|
|
78
82
|
def parent_topic
|
|
79
|
-
Topic
|
|
83
|
+
Thredded::Topic
|
|
80
84
|
.where(messageboard: messageboard)
|
|
81
85
|
.friendly
|
|
82
86
|
.find(params[:topic_id])
|
|
@@ -19,10 +19,10 @@ module Thredded
|
|
|
19
19
|
private
|
|
20
20
|
|
|
21
21
|
def init_preferences
|
|
22
|
-
@preferences = UserPreferencesForm.new(
|
|
22
|
+
@preferences = Thredded::UserPreferencesForm.new(
|
|
23
23
|
user: thredded_current_user,
|
|
24
24
|
messageboard: messageboard_or_nil,
|
|
25
|
-
messageboards: policy_scope(Messageboard.all),
|
|
25
|
+
messageboards: policy_scope(Thredded::Messageboard.all),
|
|
26
26
|
params: preferences_params
|
|
27
27
|
)
|
|
28
28
|
end
|
|
@@ -4,7 +4,7 @@ module Thredded
|
|
|
4
4
|
class PrivatePostPermalinksController < Thredded::ApplicationController
|
|
5
5
|
before_action :thredded_require_login!
|
|
6
6
|
def show
|
|
7
|
-
private_post = PrivatePost.find(params[:id])
|
|
7
|
+
private_post = Thredded::PrivatePost.find(params[:id])
|
|
8
8
|
authorize private_post, :read?
|
|
9
9
|
redirect_to post_url(private_post, user: thredded_current_user), status: :found
|
|
10
10
|
end
|