Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Enhancements:

Bug Fixes:

* Fix a bug which ActivityNotificaion.config.mailer configuration was ignored
* Fix a bug which ActivityNotification.config.mailer configuration was ignored

## 1.4.1 / 2017-05-17
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.4.0...v1.4.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def find_current_target(devise_type = nil)
end

# Set @target instance variable from request parameters.
# This method overrides super (ActivityNotiication::NotificationChannel#set_target)
# This method overrides super (ActivityNotification::NotificationChannel#set_target)
# to set devise authenticated target when the target_id params is not specified.
# @api protected
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def session
end

# Sets @target instance variable from request parameters.
# This method override super (ActivityNotiication::NotificationChannel#set_target)
# This method override super (ActivityNotification::NotificationChannel#set_target)
# to set devise authenticated target when the target_id params is not specified.
# @api protected
# @return [Object] Target instance (Reject subscription when request parameters are not enough)
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/activity_notification/notify_all_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ActivityNotification::NotifyAllJob < ActivityNotification.config.parent_jo
# @option options [Boolean] :send_email (true) Whether it sends notification email
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
# @return [Array<Notificaion>] Array of generated notifications
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options
# @return [Array<Notification>] Array of generated notifications
def perform(targets, notifiable, options = {})
ActivityNotification::Notification.notify_all(targets, notifiable, options)
end
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/activity_notification/notify_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ActivityNotification::NotifyJob < ActivityNotification.config.parent_job.c
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
# @option options [Boolean] :pass_full_options (false) Whether it passes full options to notifiable.notification_targets, not a key only
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
# @return [Array<Notificaion>] Array of generated notifications
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options
# @return [Array<Notification>] Array of generated notifications
def perform(target_type, notifiable, options = {})
ActivityNotification::Notification.notify(target_type, notifiable, options)
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/activity_notification/notify_to_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ActivityNotification::NotifyToJob < ActivityNotification.config.parent_job
# @option options [Boolean] :send_email (true) Whether it sends notification email
# @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously
# @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options
# @option options [Hash<String, Hash>] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options
# @return [Notification] Generated notification instance
def perform(target, notifiable, options = {})
ActivityNotification::Notification.notify_to(target, notifiable, options)
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/activity_notification/mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if defined?(ActionMailer)
# Mailer for email notification of ActivityNotificaion.
# Mailer for email notification of ActivityNotification.
class ActivityNotification::Mailer < ActivityNotification.config.parent_mailer.constantize
include ActivityNotification::Mailers::Helpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Dear <%= @target.printable_target_name %>

You have recieved follwing notifications.
You have received the following notifications.

<% @notifications.each do |notification| %>
<%= notification.notifier.present? ? notification.notifier.printable_notifier_name : 'Someone' %> notified you of <%= notification.notifiable.printable_notifiable_name(notification.target) %><%= " in #{notification.group.printable_group_name}" if notification.group.present? %>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
$(".notifications").prepend(notification.group_owner_view);
$(".notification_count").html("<span class=unopened>" + notification.unopened_notification_count + "</span>");
}
// Push notificaion using Web Notification API by Push.js
// Push notification using Web Notification API by Push.js
Push.create('ActivityNotification', {
body: notification.text,
timeout: 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<% target.notifications.filtered_by_key(key).latest.optional_target_names.each do |optional_target_name| %>
<div class="field_label">
<label>
Optional tagret (<%= optional_target_name %>)
Optional target (<%= optional_target_name %>)
</label>
</div>
<div class="field">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<% subscription.optional_target_names.each do |optional_target_name| %>
<div class="field_label">
<label>
Optional tagret (<%= optional_target_name %>)
Optional target (<%= optional_target_name %>)
</label>
</div>
<div class="field">
Expand Down
16 changes: 8 additions & 8 deletions docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ config.subscribe_to_email_as_default = false
config.subscribe_to_optional_targets_as_default = true
```

However if **subscribe_as_default** is not enabled, **subscribe_to_email_as_default** and **subscribe_to_optional_targets_as_default** won't change anything.
However, if **subscribe_as_default** is not enabled, **subscribe_to_email_as_default** and **subscribe_to_optional_targets_as_default** won't change anything.

##### Creating and updating subscriptions

Expand Down Expand Up @@ -860,7 +860,7 @@ See [Devise Token Auth documents](https://devise-token-auth.gitbook.io/devise-to

*activity_notification* supports push notification with Action Cable by WebSocket.
*activity_notification* only provides Action Cable channels implementation, does not connections.
You can use default implementaion in Rails or your custom `ApplicationCable::Connection` for Action Cable connections.
You can use default implementation in Rails or your custom `ApplicationCable::Connection` for Action Cable connections.

#### Enabling broadcasting notifications to channels

Expand Down Expand Up @@ -928,7 +928,7 @@ You can simply create subscriptions for the specified target in your view like t
received: function(notification) {
// Display notification

// Push notificaion using Web Notification API by Push.js
// Push notification using Web Notification API by Push.js
Push.create('ActivityNotification', {
body: notification.text,
timeout: 5000,
Expand Down Expand Up @@ -978,7 +978,7 @@ export default {
notify (data) {
// Display notification

// Push notificaion using Web Notification API by Push.js
// Push notification using Web Notification API by Push.js
Push.create('ActivityNotification', {
body: data.notification.text,
timeout: 5000,
Expand Down Expand Up @@ -1045,7 +1045,7 @@ App.activity_notification = App.cable.subscriptions.create(

*ActivityNotification::NotificationWithDeviseChannel* will confirm subscription requests from authenticated cookies by Devise. If the user has not signed in, the subscription request will be rejected. If the user has signed in as unauthorized user, the subscription request will be also rejected.

In addtion, you can use `Target#notification_action_cable_channel_class_name` method to select channel class depending on your *action_cable_with_devise* configuration for the target.
In addition, you can use `Target#notification_action_cable_channel_class_name` method to select channel class depending on your *action_cable_with_devise* configuration for the target.

```js
App.activity_notification = App.cable.subscriptions.create(
Expand Down Expand Up @@ -1253,7 +1253,7 @@ First, add **slack-notifier** gem to your Gemfile and create Incoming WebHooks i
gem 'slack-notifier'
```

Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set *ActivityNotification::OptionalTarget::Slack* to *acts_as_notifiable* with *:webhook_url* and *:target_username* initializing parameters. *:webhook_url* is created WebHook URL and required, *:target_username* is target's slack user name as String value, symbol method name or lambda function and is optional.
Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set *ActivityNotification::OptionalTarget::Slack* to *acts_as_notifiable* with *:webhook_url* and *:target_username* initializing parameters. *:webhook_url* is created WebHook URL and required, *:target_username* is target's slack username as String value, symbol method name or lambda function and is optional.
Any other options for `Slack::Notifier.new` are available as initializing parameters. See [Github slack-notifier](https://github.com/stevenosloan/slack-notifier) and [API Reference of Class: Slack::Notifier](http://www.rubydoc.info/gems/slack-notifier/1.5.1/Slack/Notifier) for more details.

```ruby
Expand Down Expand Up @@ -1323,10 +1323,10 @@ end
*ActivityNotification::Subscription* model provides API to subscribe and unsubscribe optional notification targets. Call these methods with optional target name like this:

```ruby
# Subscribe Acltion Cable channel for 'comment.reply' notifications
# Subscribe Action Cable channel for 'comment.reply' notifications
user.find_or_create_subscription('comment.reply').subscribe_to_optional_target(:action_cable_channel)

# Subscribe Acltion Cable API channel for 'comment.reply' notifications
# Subscribe Action Cable API channel for 'comment.reply' notifications
user.find_or_create_subscription('comment.reply').subscribe_to_optional_target(:action_cable_api_channel)

# Unsubscribe Slack notification for 'comment.reply' notifications
Expand Down
14 changes: 7 additions & 7 deletions docs/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ bin/rails generate activity_notification:install
```

The generator will install an initializer which describes all configuration options of *activity_notification*.
It also generates a i18n based translation file which we can configure the presentation of notifications.
It also generates an i18n based translation file which we can configure the presentation of notifications.

#### ORM Dependencies

Expand Down Expand Up @@ -147,7 +147,7 @@ In such cases, you can use **store_with_associated_records** option in initializ
config.store_with_associated_records = true
```

When **store_with_associated_records** is set to *false* as default, *activity_notification* stores notificaion records with association like this:
When **store_with_associated_records** is set to *false* as default, *activity_notification* stores notification records with association like this:

```json
{
Expand Down Expand Up @@ -181,7 +181,7 @@ When **store_with_associated_records** is set to *false* as default, *activity_n
}
```

When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable, notifier and several instance methods like this:
When you set **store_with_associated_records** to *true*, *activity_notification* stores notification records including associated target, notifiable, notifier and several instance methods like this:

```json
{
Expand Down Expand Up @@ -561,7 +561,7 @@ ActivityNotification::Notification.notify :users, @comment, key: "comment.reply"
The first argument is the plural symbol name of your target model, which is configured in notifiable model by *acts_as_notifiable*.
The new instances of **ActivityNotification::Notification** model will be generated for the specified targets.

*Hint*: *:key* is a option. Default key `#{notifiable_type}.default` which means *comment.default* will be used without specified key.
*Hint*: *:key* is an option. Default key `#{notifiable_type}.default` which means *comment.default* will be used without specified key.
You can override it by *Notifiable#default_notification_key*.

#### Asynchronous notification API with ActiveJob
Expand All @@ -580,7 +580,7 @@ You can also use *:notify_later* option in *notify* method. This is the same ope

*Note*: *notify_now* is an alias for *notify* and does the same.

When you use asynchronous notification API, you should setup ActiveJob with background queuing service such as Sidekiq.
When you use asynchronous notification API, you should set up ActiveJob with background queuing service such as Sidekiq.
You can set *config.active_job_queue* in your initializer to specify a queue name *activity_notification* will use.
The default queue name is *:activity_notification*.

Expand Down Expand Up @@ -725,7 +725,7 @@ For example, if you have a notification with *:key* set to *"notification.commen

*Hint*: the *"notification."* prefix in *:key* is completely optional, you can skip it in your projects or use this prefix only to make namespace.

If you would like to fallback to a partial, you can utilize the **:fallback** parameter to specify the path of a partial to use when one is missing:
If you would like to fall back to a partial, you can utilize the **:fallback** parameter to specify the path of a partial to use when one is missing:

```erb
<%= render_notification(@notification, target: :users, fallback: :default) %>
Expand All @@ -741,7 +741,7 @@ If you do not specify *:target* option like this,

the gem will look for a partial in *default* as the target type which means *activity_notification/notifications/default/_default.html.(|erb|haml|slim|something_else)*.

If a view file does not exist then *ActionView::MisingTemplate* will be raised. If you wish to fallback to the old behaviour and use an i18n based translation in this situation you can specify a *:fallback* parameter of *:text* to fallback to this mechanism like such:
If a view file does not exist then *ActionView::MisingTemplate* will be raised. If you wish to fall back to the old behaviour and use an i18n based translation in this situation you can specify a *:fallback* parameter of *:text* to fall back to this mechanism like such:

```erb
<%= render_notification(@notification, fallback: :text) %>
Expand Down
2 changes: 1 addition & 1 deletion docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ $ export AN_ORM=dynamoid AN_TEST_DB=postgresql
```

Then, configure *spec/rails_app/config/database.yml* or *spec/rails_app/config/mongoid.yml*, *spec/rails_app/config/dynamoid.rb* as your local database.
Finally, run database migration, seed data script and the example appliation.
Finally, run database migration, seed data script and the example application.
```console
$ cd spec/rails_app
$ # You don't need migration when you use MongoDB only (AN_ORM=mongoid and AN_TEST_DB=mongodb)
Expand Down
Loading
Loading