thredded 0.13.3 → 0.13.4
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/assets/stylesheets/thredded/components/_form-list.scss +2 -1
- data/app/commands/thredded/notify_following_users.rb +39 -21
- data/app/views/thredded/preferences/_form.html.erb +9 -9
- data/app/views/thredded/topics/_topic.html.erb +2 -1
- data/app/views/thredded/topics/index.html.erb +6 -1
- data/config/locales/pl.yml +1 -2
- data/config/locales/ru.yml +1 -2
- data/lib/thredded.rb +1 -0
- data/{app/notifiers → lib}/thredded/base_notifier.rb +0 -0
- data/lib/thredded/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f51494c108c361f5f0d96441cf9bb0615f388d3
|
4
|
+
data.tar.gz: 0f98a9b720385ee57a189aaf42116d52b60bff87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f7a755ef708111bd17e06da26f684e870334f0b3acf0a555cb6d18a767f8e93858d9e04d7c9a90d69aded4dc8abacd9c295181e3808c6b30902b9d152476b8
|
7
|
+
data.tar.gz: 15b3f0169e31a3bf7938cee0eef98111967668e15f97aadf57b81af02e8a4c281863eeca013bab9a4535c243dad42c9e144623482cdfe1b266640af70601a4cf
|
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.13.
|
101
|
+
gem 'thredded', '~> 0.13.4'
|
102
102
|
```
|
103
103
|
|
104
104
|
Add the Thredded [initializer] to your parent app by running the install generator.
|
@@ -9,47 +9,65 @@ 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
73
|
@messageboard_notifier_prefs_by_user_id ||= Thredded::MessageboardNotificationsForFollowedTopics
|
@@ -3,8 +3,8 @@
|
|
3
3
|
class: 'thredded--form thredded--notification-preferences-form',
|
4
4
|
'data-thredded-user-preferences-form' => true
|
5
5
|
}) do |f| %>
|
6
|
-
<ul class="thredded--form-list">
|
7
|
-
<li>
|
6
|
+
<ul class="thredded--form-list thredded--user-preferences-global">
|
7
|
+
<li class="thredded--user-preferences--auto-follow-topics">
|
8
8
|
<%= f.label :auto_follow_topics do %>
|
9
9
|
<%= f.check_box :auto_follow_topics,
|
10
10
|
'data-thredded-update-checkbox-on-change' =>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
</p>
|
16
16
|
<% end %>
|
17
17
|
</li>
|
18
|
-
<li>
|
18
|
+
<li class="thredded--user-preferences--follow-topics-on-mention">
|
19
19
|
<%= f.label :follow_topics_on_mention do %>
|
20
20
|
<%= f.check_box :follow_topics_on_mention, 'data-thredded-bound-messageboard-pref' => 'user_preferences_form[messageboard_follow_topics_on_mention]' %>
|
21
21
|
<%= t 'thredded.preferences.form.follow_topics_on_mention.label' %>
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<% end %>
|
26
26
|
</li>
|
27
27
|
<% if Thredded.notifiers.present? %>
|
28
|
-
<li>
|
28
|
+
<li class="thredded--user-preferences--notifications-for-followed-topics">
|
29
29
|
<label><%= t 'thredded.preferences.form.notifications_for_followed_topics.label' %></label>
|
30
30
|
<%= f.fields_for :notifications_for_followed_topics, preferences.notifications_for_followed_topics do |fn| %>
|
31
31
|
<%= fn.label :enabled do %>
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<%- end %>
|
38
38
|
<%- end %>
|
39
39
|
</li>
|
40
|
-
<li>
|
40
|
+
<li class="thredded--user-preferences--notifications-for-private-topics">
|
41
41
|
<label><%= t 'thredded.preferences.form.notifications_for_private_topics.label' %></label>
|
42
42
|
<%= f.fields_for :notifications_for_private_topics, preferences.notifications_for_private_topics do |fn| %>
|
43
43
|
<%= fn.label :enabled do %>
|
@@ -53,8 +53,8 @@
|
|
53
53
|
<h2 class="thredded--preferences--title">
|
54
54
|
<%= t 'thredded.preferences.messageboard_preferences_title_html', messageboard: messageboard.name %>
|
55
55
|
</h2>
|
56
|
-
<ul class="thredded--form-list" data-thredded-user-preferences-form-messageboard-fields>
|
57
|
-
<li>
|
56
|
+
<ul class="thredded--form-list thredded--user-preferences-messageboard" data-thredded-user-preferences-form-messageboard-fields>
|
57
|
+
<li class="thredded--user-preferences--auto-follow-topics">
|
58
58
|
<%= f.label :messageboard_auto_follow_topics do %>
|
59
59
|
<%= f.check_box :messageboard_auto_follow_topics %>
|
60
60
|
<%= t 'thredded.preferences.form.messageboard_auto_follow_topics.label' %>
|
@@ -63,7 +63,7 @@
|
|
63
63
|
</p>
|
64
64
|
<% end %>
|
65
65
|
</li>
|
66
|
-
<li>
|
66
|
+
<li class="thredded--user-preferences--follow-topics-on-mention">
|
67
67
|
<%= f.label :messageboard_follow_topics_on_mention do %>
|
68
68
|
<%= f.check_box :messageboard_follow_topics_on_mention %>
|
69
69
|
<%= t 'thredded.preferences.form.messageboard_follow_topics_on_mention.label' %>
|
@@ -73,7 +73,7 @@
|
|
73
73
|
<% end %>
|
74
74
|
</li>
|
75
75
|
<% if Thredded.notifiers.present? %>
|
76
|
-
<li>
|
76
|
+
<li class="thredded--user-preferences--notifications-for-followed-topics">
|
77
77
|
<label><%= t 'thredded.preferences.form.messageboard_notifications_for_followed_topics.label' %></label>
|
78
78
|
<%= f.fields_for :messageboard_notifications_for_followed_topics,
|
79
79
|
preferences.messageboard_notifications_for_followed_topics do |fn| %>
|
@@ -41,6 +41,7 @@
|
|
41
41
|
<% end %>
|
42
42
|
<% end %>
|
43
43
|
|
44
|
-
<% if
|
44
|
+
<% if local_assigns[:sticky_topics_divider] &&
|
45
|
+
!topic_iteration.last? && topic.sticky? && !topics[topic_counter + 1].sticky? %>
|
45
46
|
<%= render 'thredded/topics/sticky_topics_divider' %>
|
46
47
|
<% end %>
|
@@ -13,7 +13,12 @@
|
|
13
13
|
topic: @new_topic,
|
14
14
|
css_class: 'thredded--is-compact',
|
15
15
|
placeholder: t('thredded.topics.form.title_placeholder_start') if @new_topic %>
|
16
|
-
<%= render partial: 'thredded/topics/topic',
|
16
|
+
<%= render partial: 'thredded/topics/topic',
|
17
|
+
collection: @topics,
|
18
|
+
locals: {
|
19
|
+
sticky_topics_divider: true,
|
20
|
+
topics: @topics
|
21
|
+
} %>
|
17
22
|
<% end %>
|
18
23
|
|
19
24
|
<footer class="thredded--pagination-bottom">
|
data/config/locales/pl.yml
CHANGED
@@ -25,8 +25,7 @@ pl:
|
|
25
25
|
unsubscribe_instructions: :thredded.emails.post_notification.text.unsubscribe_instructions
|
26
26
|
post_notification:
|
27
27
|
html:
|
28
|
-
email_sent_reason_html:
|
29
|
-
Ten e-mail został wysłany do Ciebie, ponieważ śledzisz ten temat: "<a href="%{post_url}">%{topic_title}</a>".
|
28
|
+
email_sent_reason_html: 'Ten e-mail został wysłany do Ciebie, ponieważ śledzisz ten temat: "<a href="%{post_url}">%{topic_title}</a>".'
|
30
29
|
post_lead_html: '%{user} <a href="%{post_url}">powiedział w "%{topic_title}"</a>:'
|
31
30
|
unsubscribe_instructions_html: Aby wypisać się z tych e-maili, zaktualizuj swoje <a href="%{preferences_url}">preferencje</a>.
|
32
31
|
subject: Nowy post w "%{topic_title}" przez %{user}
|
data/config/locales/ru.yml
CHANGED
@@ -25,8 +25,7 @@ ru:
|
|
25
25
|
unsubscribe_instructions: :thredded.emails.post_notification.text.unsubscribe_instructions
|
26
26
|
post_notification:
|
27
27
|
html:
|
28
|
-
email_sent_reason_html:
|
29
|
-
Это письмо было отправлено вам, потому что вы подписаны на тему: «<a href="%{post_url}">%{topic_title}</a>».
|
28
|
+
email_sent_reason_html: 'Это письмо было отправлено вам, потому что вы подписаны на тему: «<a href="%{post_url}">%{topic_title}</a>».'
|
30
29
|
post_lead_html: '%{user} в <a href="%{post_url}">«%{topic_title}»</a>:'
|
31
30
|
unsubscribe_instructions_html: Чтобы отписаться от этих писем, обновите свои <a href="%{preferences_url}">настройки</a>.
|
32
31
|
subject: Новое сообщение в «%{topic_title}» от %{user}
|
data/lib/thredded.rb
CHANGED
@@ -37,6 +37,7 @@ require 'thredded/view_hooks/renderer'
|
|
37
37
|
# Require these explicitly so that they do not need to be required if used in the initializer:
|
38
38
|
require 'thredded/content_formatter'
|
39
39
|
require 'thredded/email_transformer'
|
40
|
+
require 'thredded/base_notifier'
|
40
41
|
|
41
42
|
require 'thredded/collection_to_strings_with_cache_renderer'
|
42
43
|
|
File without changes
|
data/lib/thredded/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thredded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Oliveira
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pundit
|
@@ -569,14 +569,14 @@ dependencies:
|
|
569
569
|
requirements:
|
570
570
|
- - ">="
|
571
571
|
- !ruby/object:Gem::Version
|
572
|
-
version:
|
572
|
+
version: 0.9.18
|
573
573
|
type: :development
|
574
574
|
prerelease: false
|
575
575
|
version_requirements: !ruby/object:Gem::Requirement
|
576
576
|
requirements:
|
577
577
|
- - ">="
|
578
578
|
- !ruby/object:Gem::Version
|
579
|
-
version:
|
579
|
+
version: 0.9.18
|
580
580
|
- !ruby/object:Gem::Dependency
|
581
581
|
name: web-console
|
582
582
|
requirement: !ruby/object:Gem::Requirement
|
@@ -840,7 +840,6 @@ files:
|
|
840
840
|
- app/models/thredded/user_private_topic_read_state.rb
|
841
841
|
- app/models/thredded/user_topic_follow.rb
|
842
842
|
- app/models/thredded/user_topic_read_state.rb
|
843
|
-
- app/notifiers/thredded/base_notifier.rb
|
844
843
|
- app/notifiers/thredded/email_notifier.rb
|
845
844
|
- app/policies/thredded/messageboard_group_policy.rb
|
846
845
|
- app/policies/thredded/messageboard_policy.rb
|
@@ -994,6 +993,7 @@ files:
|
|
994
993
|
- lib/tasks/thredded_tasks.rake
|
995
994
|
- lib/thredded.rb
|
996
995
|
- lib/thredded/base_migration.rb
|
996
|
+
- lib/thredded/base_notifier.rb
|
997
997
|
- lib/thredded/collection_to_strings_with_cache_renderer.rb
|
998
998
|
- lib/thredded/content_formatter.rb
|
999
999
|
- lib/thredded/database_seeder.rb
|