Git Product home page Git Product logo

simukappu / activity_notification Goto Github PK

View Code? Open in Web Editor NEW
473.0 14.0 79.0 4.95 MB

Integrated user activity notifications for Ruby on Rails

Home Page: https://rubygems.org/gems/activity_notification

License: MIT License

Ruby 89.05% HTML 5.74% JavaScript 1.14% CSS 0.54% Roff 0.10% Shell 0.24% Vue 3.18% Procfile 0.01%
rails rails-gem notification notification-api activity-notification email-notification

activity_notification's Introduction

Hi there 👋

I'm Solutions Architect, and contributing open source as its developer/maintainer for my cup of tea.

  • I'm interested in cloud architecture, distributed systems, big data analytics and new AI technology.
  • I'm also passionate about applying new computing technologies to solve real-world problems and create value for our society.

activity_notification's People

Contributors

bastianwegge avatar eth3rnit3 avatar euanlau avatar finnwoelm avatar hhff avatar johannesengl avatar josephktcheung avatar kiskoza avatar markedmondson avatar moeomer avatar onk avatar onshi avatar ryanquey avatar simukappu avatar szechyjs avatar upstill avatar vipera avatar zll11111 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activity_notification's Issues

Class name typo

This is a very minor issue, but it might be worth changing module DeviceAuthenticationController (for example, from activity_notification/lib/activity_notification/controllers/devise_authentication_controller.rb) to DeviseAuthenticationController (using an 's' instead of a 'c')

ActivityNotification with commontator

I'm trying to use the ActivityNotification gem with the commontator. My model with comments is Post.rb. I generate the model of commontator and then put the code below, but I'm not receiving any notification. Is that correct? It is like the documentation.

module Commontator
  class Comment < ActiveRecord::Base

# acts_as_notifiable configures your model as ActivityNotification::Notifiable
  # with parameters as value or custom methods defined in your model as lambda or symbol.
  # The first argument is the plural symbol name of your target model.
  acts_as_notifiable :users,
  # Notification targets as :targets is a necessary option
  # Set to notify to author and users commented to the article, except comment owner self
  targets: ->(follow, key) {
    ([follow.user] + follow.user.to_a - [follow.user]).uniq
  },
  # Path to move when the notification is opened by the target user
  # This is an optional configuration since activity_notification uses polymorphic_path as default

403 Forbidden: Unauthenticated

someone with the same issue configuring with devise?

after added notify_to :users, with_devise: :users in the routes?

Started GET "/users/bopa/notifications" for 127.0.0.1 at 2018-04-10 17:57:28 -0300
Processing by ActivityNotification::NotificationsWithDeviseController#index as HTML
  Parameters: {"target_type"=>"users", "devise_type"=>"users", "user_id"=>"bopa"}
  Rendering text template
  Rendered text template (0.1ms)
Filter chain halted as :authenticate_devise_resource! rendered or redirected
Completed 403 Forbidden in 6ms (Views: 4.4ms)

Error while running migration

Hello,

Great job with this gem. I'm really excited about using it. I am currently trying it out on Rails 5.2 and I'm getting this error:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateActivityNotificationTables < ActiveRecord::Migration[4.2]
/Users/andrei/.rvm/gems/ruby-2.5.0@app/gems/activerecord-5.2.0.beta2/lib/active_record/migration.rb:527:in `inherited'

Are namespaces supported?

I am having problems adding notifications under an admin namespace.

Some background, the app has a single public page which is used to submit some information and the remaining functionality is used by administrators.

# /config/routes.rb
Rails.application.routes.draw do
  # Public routes (a form on the home#index POST's to information#create
  resources :information, only: %i(create)
  root to: 'home#index'

  # Admin section
  namespace :admin do
    devise_for :users, ...

    notify_to :users, controller: '/activity_notification/notifications'

    # Some other information model related routes
    resources :information, only: %i(edit index show update)
  end
end

The user and notifiable models are basic:

# /app/models/user.rb
class User < ApplicationRecord
  acts_as_notifier
  acts_as_target email: :email_address, email_allowed: true


# /app/models/information.rb
class Information < ApplicationRecord
  acts_as_notifiable :users,
                     email_allowed: true,
                     notifier: ->(user, key) { user },
                     notifiable_path: ->(information, key) { [:admin, information] },
                     tracked: true,
                     targets: -> (information, key) { User.where(role: 'admin').to_a },
                     printable_notifier_name: ->(user, key) { user }

However, when visiting http://localhost:5000/admin/users/1/notifications

I receive the following error:

undefined method `open_all_user_notifications_path' for #<#<Class...

    # @todo Must handle devise namespace
    def open_all_notifications_path_for(target, params = {})
      send("open_all_#{target.to_resource_name}_notifications_path", target, params)
    end

Which I assume is caused by the target being User and the view helpers not supporting nesting, unless of course I'm (hopefully) missing something simple.

Mailer jobs not cleaned up when a notification is destroyed

I'm using this awesome gem and I have a notifiable model with dependent_notifications: :destroy enabled. The issue is that if the notifiable is created and shortly destroyed before the mailer job is performed, I get a Couldn't find ActivityNotification::Notification with 'id'=xyz error in the background jobs cause the corresponding notification is destroyed. I know this is an edge case, but there is a real case for it, in my case, the notifiable is a "Like" action and if user clicks on Like and UnLike quickly this happens.
I also couldn't keep the notifications around after the notifiable is destroyed cause the email template then can't find the Notifiable to generate an email.

Is it supposed to work on Rails 5.1?

Hi there!

Has anyone tested the gem with Rails 5.1? I mean, probably I'm doing something wrong.
It's a bit confusing when after "bin/rails generate activity_notification:install" it says I should have:

include ActivityNotification::Notifiable
acts_as_notifiable :users ...
include ActivityNotification::Target
acts_as_target email: :email, email_allowed: :confirmed_at

But in readme it doesn't say to include 'includes'.

What's the right way?

Thanks,
Ben

Rails 5.2 - Only one email notification gets sent

Only one notification email gets sent, then if I restart the server I can send another one.

I have no idea how to fix this :(

Here is video demonstrating the issue.
http://somup.com/cFe026Vgmd
I start by restarting docker and I send a Notification.. It works the first time
Then I restart docker and it works again only the first time

user.rb (Model)

acts_as_target email: :email, email_allowed: :created_at

comment.rb (Model)

acts_as_notifiable :users,
    targets: ->(comment, key) {
      ([comment.commentable.user] + comment.commentable.commented_users.to_a - [comment.user]).uniq
    },
    tracked: true,
    email_allowed: true,
    notifiable_path: :commentable_notifiable_path

I tested this locally and on staging and its the same behaviour :(

Cannot install without ActiveRecord

Hi
I installed the activity_notification gem by editing Gemfile and running bundle install, but whenever i run bin/rails generate activity_notification:install in terminal, I get error "Gem Load Error is: uninitialized constant ActiveRecord". Also, i get the same error while trying to run rails server or console. When i require active record in application, it gives me error "Could not load database configuration. No such file - ["config/database.yml"] (RuntimeError)". Is it possible to install gem without active record as i dont use it anywhere in my app.
I'm using MongoDB without Active Record.
Thanks

Custom controller

Need some guidance here, I created my custom controller users/notifications_controller and set the notify accordingly in the routes, as per the instructions on the README, and even though the notifications do seem routed to it doing a binding.pry in there doesn't work, seems like it's hitting the default controller anyway, how can I route it to my controller?

ActionView::Template::Error: No route matches during email notification

Hi, I get error presented below every time I invoke notification. The regular notification comes is but email doesn't because of the error.

ActionView::Template::Error: No route matches {:action=>"move", 
:controller=>"activity_notification/notifications_with_devise", :devise_type=>"users", :id=>nil, 
:locale=>#<User id: 7, username: "nowy",...

This is a fragment of my routes.rb file:

scope "/(:locale)", locale: /#{ I18n.available_locales.join("|") }/ do

    devise_for :users, skip: :omniauth_callbacks, controllers: {
      registrations: 'users/registrations',
      confirmations: 'users/confirmations',
      sessions: 'users/sessions'
    }

    notify_to :users, with_devise: :users
    ...

I've got notifications defined like this:

class User < ActiveRecord::Base
  acts_as_target email: :email, email_allowed: :confirmed_at
  acts_as_notifier printable_name: :username
  ...
class Comment < ActiveRecord::Base

  acts_as_notifiable :users,
    targets: -> (comment, key){
      if comment.owner.is_a?(Place)
        ba_places = comment.owner.business_account_places
        if ba_places.any?
          person_to_notify = ba_places.first.business_account.user
          ([person_to_notify] - [comment.user])
        else
          []
        end
      else
        []
      end
    },
    notifier: :user,
    email_allowed: true,
    notifiable_path: :place_notifiable_path

I've got config set to enable email by default. Any ideas how I could fix this? I need both the notification and email to be sent to user.

Single Table Inheritance on target user

I'm having trouble with single table inheritance on my devise user (例えば, BuyerUser < User(devise) and SellerUser < User(devise). When I try to look at notifications for a BuyerUser, I get "Defferent type of current resource BuyerUser with devise resource SellerUser has been passed to SellerUser#authenticated_with_devise?. You have to override SellerUser#authenticated_with_devise? method or set devise_resource in acts_as_target."

What do you think? Is there a way to tell it to always use the superclass as the devise resource for both types of derived classes?

(ところで、違うのは「different」です。)

Unread Notification Button When Deployed on Heroku

Hi Folks,

When running my app locally, my unread notification button works normally (the notification button turns red and the number is changed to how many unread notifications I have).

For some reason, when deployed to Heroku, the unread notification button doesn't work correctly (the button remains grey and the number stays at 0). Everything else seems to be working properly though (if I open up the notification center, it shows that I did indeed receive a notification and will link me to it).

Is there any reason why the button color/count isn't changing when deployed on Heroku?

Really stumped on this one, thanks!

Misspelled class name in the generated view

classes called "unopened_wrapper" instead of "unopned_wrapper"
see here

(activity_notification/app/views/activity_notification/notifications/default/_default.html.erb:46)

<div class="unopened_wrapper"></div>

Making the correction doesn't change my view as things currently stand, but since there is no CSS for the class "unopened_wrapper", I figured it must of been a typo

Emails not being sent

Hello,

I followed the documentation in the README, and I can't seem to get emails to send. I'm getting the notifications I expect in the notifications index page, but I'm not getting emails for subscribed users. I've enabled emails with config.email_enabled = true. In production.rb, my email is configured as such

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      user_name: ENV['SENDGRID_USERNAME'],
      password: ENV['SENDGRID_PASSWORD'],
      domain: 'heroku.com',
      address: 'smtp.sendgrid.net',
      port: 587,
      authentication: :plain,
      enable_starttls_auto: true
  }

My user.rb model is configured as such: acts_as_target email: :email, email_allowed: :activated_at.

My notifiable model is configured as such:

acts_as_notifiable :users,
                   targets: ->(_model, _key) {User.all.to_a},
                   tracked: true

Bug in Subscriber Concern?

I've been trying to get subscriptions for optional targets to work. I have the option to automatically subscribe to notifications on false. But kept running into the following error:

ArgumentError: wrong number of arguments (given 0, expected 1..2)
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/subscription_api.rb:147:in `subscribing_to_optional_target?'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/models/concerns/subscriber.rb:175:in `evaluate_subscription'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/models/concerns/subscriber.rb:162:in `_subscribes_to_optional_target?'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/models/concerns/target.rb:466:in `subscribes_to_optional_target?'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:515:in `optional_target_subscribed?'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:357:in `block in publish_to_optional_targets'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:355:in `map'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:355:in `publish_to_optional_targets'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:225:in `notify_to'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/models/concerns/target.rb:318:in `notify_to'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:192:in `block in notify_all'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:192:in `map'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:192:in `notify_all'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/apis/notification_api.rb:169:in `notify'
api_1    | /usr/local/bundle/gems/activity_notification-1.5.0/lib/activity_notification/models/concerns/notifiable.rb:249:in `notify'

I tracked the issue down to the following line:

default ? record.blank? || record.send(field, *args) : record.present? && record.send(field)

I think the issue here is that if default is false then record.send(field) gets called. But shouldn't it be record.send(field, *args) ?

Subscriptions for specific notifiable?

Using the documentation example of articles/comments, is there a way to subscribe the user to the comments of a specific article baked into activity_notification? As far as I can tell, subscriptions are key based and I could accomplish this by embedding the article's ID in the notification's key. Is there a better way? Would this be bad practice?

Thank you!

A way to access notifiable details in notifiable_path

Hey,

I was just wondering if there's a way to access the notifiable details in the notifiable_path. I'm doing something like this:

  acts_as_notifiable :users,
                     targets: ->(object, key) {
                       get_notifiable_user_array_for(object, key)
                     },
                     notifiable_path: :objects_notifiable_path

Now since my object is pretty complex and has about 8 different notification-keys I'm wondering if I can access the key to adjust the notifiable_path the user is sent to. I'm using a basic tabs-layout on the detail page of my object that accepts /objects/5#documents for example.

I know this is something I could ask on Stackoverflow but since it has to do with a complex usage-example of your library I was wondering if there's a solution that might improve the docs as well.

All the best!

Can't create Notification in Rails 5 (likely due to belongs_to needing optional)

With a boilerplate setup in Rails 5:

class User < ApplicationRecord
  acts_as_target email: :email
end
class Invite < ApplicationRecord
  acts_as_notifiable :users,
    targets: -> (invite, key) {
      [invite.receiver]
    }
end
@invite.notify :users

No notifications are being created. Tracing the call through to the create(notification_fields) line, I can see that the validation message is:

{
   :group => [
        [0] "must exist"
    ],
    :notifier => [
        [0] "must exist"
    ]
}

My guess is that we need extra optional belongs_to params, like this one:
https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/orm/active_record/notification.rb#L35

Is this correct, or am I missing something? I don't need grouping for this feature, and I don't understand the notifier field.

When create some data, it won't create the notification

i've some trouble using gem activity_notification.

currenly i've tried to create notification when user create comment or reply a comment from another user. but unfortunately it won't create/trigger the gem function

my question is "why it wont create/trigger the gem" even i've configure as your documentation

here's my code
#Model User

class User < ApplicationRecord
  audited

  with_options dependent: :destroy do |assoc|
    assoc.has_many :forums, class_name: 'Communication::Forum'
    assoc.has_many :favorited_forums, class_name: 'Communication::FavoritedForum'
    assoc.has_many :comments
    assoc.has_many :likes
  end

  acts_as_target
end

#Model Forum

class Communication::Forum < ApplicationRecord
  audited
  belongs_to :user

  acts_as_commentable

  has_many :likes, as: :likeable
  has_many :favorited_forums, class_name: "Communication::FavoritedForum"

end

#Model Comment

class Comment < ActiveRecord::Base
  audited
  acts_as_nested_set scope: [:commentable_id, :commentable_type]
  belongs_to :commentable, polymorphic: true

  acts_as_notifiable :users,
    targets: ->(comment, key) {
      ([comment.commentable.user] + [comment.user]).uniq
    }

end

i'll really appreciate any kind of help,

Notifications beween one model

e.g. I need to implement a user friendship request so one user sends request to another user and that another user should see a notification. When I do my model User both acts_as_notification_target and acts_as_notifiable, I pass to targets user object whom sent a request but anyway only sender gets notification, not reciever user(@user.notify :users and in target is a receiver user). Even if I hard-code recevier instance only sender gets it. What am I doing wrong or how to resolve that?! Thanks
P.S. There're some other notifiables thus my User model must have acts_as_notification_target anyway.

How do I use in gem external to rails project?

I'm organizing my code such that the particular model I want to use activity_notification (User) lives in its own gem. This gem is then included by my rails application wherein I have such files as config/initializers/activity_notification.rb. Unfortunately this split does not appear to work, producing the error "uninitialized constant ActivityNotification::Target::Association" if I use acts_as_notification_target + require "activity_notification" (without the require I get undefined local variable or method `acts_as_notification_target").

I have followed the instructions for setup and have the initializer defined in the rails project including this gem. My hunch is that it has to do with needing to run the config initializer before the gem load, which doesn't happen by default and I'm not sure how to make that go.

Thank you in advance.

overriding notification email subject

I am trying to override the subject for the emails that get sent out.

I put the following in my notifiable model ("app/models/post.rb", where I have acts_as_notifiable set):

def overriding_notification_email_subject(target, key)
  if key == "weekly.unopened"
    "You have unread notifications"
  else
    if key == "new"
      "New Post"
    elsif key == "update"
      "A Post has been updated"
    elsif key == "destroy"
      "A Post has been destroyed"
    end
  end
end

However, the subject isn't getting changed.

I also confirmed in rails console that the following returns true:

n = notification
n.notifiable.respond_to?(:overriding_notification_email_subject) && 
  n.notifiable.overriding_notification_email_subject(n.target, n.key).present?

(I'm trying to follow the logic of activity_notification/lib/activity_notification/mailers/helpers.rb:61-63).

Please let me know what I need to change to fix the subject headers, thanks!

Support Rails 5.2

Currently, the gem does not pass the tests with Rails 5.2. Work in progress.

find_or_create_subscriptions not working

Here's an error I'm getting:

irb(main):012:0> user.find_or_create_subscription(key: "action_item.comment")
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "key"
LINE 1: ..." = $1 AND "subscriptions"."target_type" = $2 AND "key"."key...
                                                             ^
: SELECT  "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = $1 AND "subscriptions"."target_type" = $2 AND "key"."key" = $3 ORDER BY "subscriptions"."id" ASC LIMIT $4

The relevant line:

from /home/deploy/apps/app/shared/bundle/ruby/2.4.0/gems/activity_notification-1.4.4/lib/activity_notification/models/concerns/subscriber.rb:33:in `find_subscription'
	from /home/deploy/apps/app/shared/bundle/ruby/2.4.0/gems/activity_notification-1.4.4/lib/activity_notification/models/concerns/subscriber.rb:42:in `find_or_create_subscription'

Question about optional_targets

Hi!

Is optional_targets works as intended? I tried implement custom SMS notifications. And i can't...

My steps:

  1. created user model with acts_as_target
  2. created other model Heat with
  require 'custom_optional_target/sms'
  acts_as_notifiable :owners,
                     targets: User.first,
                     optional_targets: {
                       CustomOptionalTarget::Sms => {}
                     }
  1. created CustomOptionalTarget::Sms, just dummy for example
module CustomOptionalTarget
  class Sms < ActivityNotification::OptionalTarget::Base
    def initialize_target(options = {})
    end

    def notify(notification, options = {})
      puts 'bingo'
    end
  end
end
  1. when i try notificate user about something from heat, Heat.last.notify(:owners, key: 'heat.ready'), CustomOptionalTarget::Sms never called. What i am doing wrong? Thanks.

CanCanCan support

Hey guys,
I was just trying to implement your gem into my legacy rails 4.2.8 app and came across an error with cancancan.
Cancancan allows me to authorize every resource by setting a check_authorization in my ApplicationController. I am not using Devise, for the record.
Cancancan throws me an error This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.
After generating your controllers and adding the skip_authorization_check flag it still does not work.
Is there a chance we can fix this? Do you need a sample app to test the behaviour?

Separate targets for email notifications

In my app users can select if they want to receive notifications via email, in system or both. Is there a way to separate targets so if a user has selected email only he only gets the email?

Problem for STI tables.

Hi all.

I use STI solution for Users, Coach < Users.

acts_as_notifiable :users, targets: -> (follow, key) { ([follow.followable]).uniq }, notifier: :follower, optional_targets: { CustomOptionalTarget::AirshipSns => { } }, tracked: true

So, how I can use multiple target_type?

For example:

acts_as_notifiable %i[users, coaches], targets: -> (follow, key) { ([follow.followable]).uniq }, notifier: :follower, optional_targets: { CustomOptionalTarget::AirshipSns => { } }, tracked: true

acts_as_notifiable %i[users, coaches]

Because
optional_targets: { CustomOptionalTarget::AirshipSns => { } }
don't work if target_type = :users but I have target = :coaches.

Thanks to all.

Unpermitted parameters

Hello. I'm having rails 5.1.3 and ruby 2.4.1p111. I am getting

Unpermitted parameters: :subdomain, :target_type, :devise_type, :user_id

in console output for @my_instance.notify :users. I have executed this code in rails console and it rolls-back. Would you kindly please offer a solution this?

controller_path protected when rendering with subscriptions

When rendering the subscriptions action (e.g. users/14/subscriptions), I get the NoMethodError since I have controller_path in my view application.html.erb

NoMethodError at /users/14/subscriptions
protected method `controller_path' called for #<ActivityNotification::SubscriptionsWithDeviseController:0x00007f98d52669a0>
Did you mean?  controller_name

The line in the application.html.erb

...
  <body class="app header-fixed sidebar-fixed aside-menu-fixed aside-menu-hidden <%= controller_path.parameterize %> <%= controller_name %> <%= action_name %>">
...

Why is this controller_path protected?

Error in the example-app

Hey guys,

I like the gem very much and we'd love to use it in one of our projects. Currently while testing your example 'rails-app' in the specs folder, I ran into the following error:

x

I guess this is not on purpose but maybe I don't understand this good enough.

Bullet doesn't support mongoid > 7.0.0

I try to test dummy application and get the error

Bundler::GemRequireError: There was an error while trying to load the gem 'bullet'.
Gem Load Error is: Bullet does not support mongoid 7.0.0 yet

Maybe you lock the mongoid in gemspec
s.add_development_dependency 'mongoid', '>= 4.0.0', '< 7.0.0'

Notification preview & mail preview

Hey @simukappu,

since I'm using activity_notification I'm now making full use of the automatic email generation you built, awesome!

It seems to me that the task to edit or even to preview the emails is a tedious one, since I always have to trigger a new notification that opens my mail preview. I've dug into the code for a while now but it seems not obvious for me how to use the rails email-preview feature with activity_notification.

I know this is generally interesting for people using it. So if you have a kind of explanation I'd be glad to improve the README oncemore.

All the best!

Weird logs - Creating scope :filtered_by_type...

Hi there!

I keep seeing this in my logs but can't figure out why:

Creating scope :filtered_by_type. Overwriting existing method ActivityNotification::ORM::ActiveRecord::Notification.filtered_by_type.

I'm not doing any kind of overwriting and there isn't anything like "filtered_by_type" in my code.

Thanks,
Ben

Paginating notifications

I see there's a way to limit the returned count of notifications but no way to set an offset, I'm guessing this is partly due to the indexed caching in the count methods, is there any simple way you can see pagination being achieved (that isn't just paginating the potentially huge array of notifications)?

Background Job support

Hello!

First off, the gem looks amazing. We just ran through a test integration and we're ecstatic that it covered all our needs and more. We're going to be fully integrating it this week but one thing we noticed was that when a notification is triggered its done entirely inline. This would fall over performance wise for us since a single comment could cause hundreds of notification records inserts. Looking through the API it looks pretty straight forward to integrate some ActiveJob queueing to handle the notification creation for these three methods:

https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/models/concerns/notifiable.rb#L240
https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/models/concerns/notifiable.rb#L260
https://github.com/simukappu/activity_notification/blob/master/lib/activity_notification/models/concerns/notifiable.rb#L280

I was going to create an option to enable / disable whether it used ActiveJob's or inline (as it currently is implemented).

First question... Is this something thats already in place but I'm just blind and missed it?

Second question in case the answer to the first is that its not in fact already in the gem.. is this something you'd want / appreciate as a pull request (presuming test coverage is in place and all the other responsible open source requirements are handled) ? I ask only because it might influence how we patch in the background job support.

Again, fantastic gem and looking forward to exploring all its goodies!

Cheers,
Sumit

Open all route broken

Hi,

when I want to access the open_all route, I get an error stating

Couldn't find ActivityNotification::Notification with 'id'=open_all

Obviously, the DB Query has to fail with this "id", but is there something I have to consider to get this working? I also tried it in your example app and get the same error.

Thanks!

Slack Notification Channel Using Symbol

My optional slack target is as follows, where '@user' is a member of the slack channel:

ActivityNotification::OptionalTarget::Slack => { webhook_url: 'https://hooks.slack.com/services/XXXXXX', target_username: :slack_username, channel: @user, username: 'system', icon_emoji: ":ghost:" }

The above works perfectly. But since I want to change the channel the message is sent to depending on the notified user, I was hoping to change the code to the below, where ':slack_username' is a User's username on slack (including the '@' sign).

ActivityNotification::OptionalTarget::Slack => { webhook_url: 'https://hooks.slack.com/services/XXXXXX', target_username: :slack_username, channel: :slack_username, username: 'system', icon_emoji: ":ghost:" }

For some reason, this does not work (comes up with a slack channel cannot be found error). Does the 'channel' parameter not accept symbols?

Thanks!

Notifier ID

Hey there,

I've got pretty much everything up and running, however when I create a new Notification record, it doesn't include a notifier_id. I added 'acts_as_notifier' to my User model – is there anything else I must do?

Thanks!

Multiple target types / acts_as_notifiable in one model

Is it possible to define two different acts_as_notifiable / target types in one model?

Depending on certain events I want to have different target types with different optional targets. Or choose optional target based on certain conditions.
Is there any way to achieve this? After going through the documentation and trying some stuff out, it seems like you can only define one target type per model. Or maybe I overlooked something?

Polymorphic comments

Hey, I'm trying to set up some notifications for comments.
I have products and polymorphic comments. And when someone comments on or likes (acts as votable) a product to get notified about this. Can you point me in the right direction :)

Thank you in advance.

Unpermitted Parameters when loading User Notifications

Is it normal for the :target_type, :devise_type, :user_id to be seen as unpermitted parameters during load time?

Processing by ActivityNotification::NotificationsWithDeviseController#index as HTML
  Parameters: {"target_type"=>"users", "devise_type"=>"users", "user_id"=>"3"}
  User Load (6.0ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 3], ["LIMIT", 1]]
  User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 3], ["LIMIT", 1]]
Unpermitted parameters: :target_type, :devise_type, :user_id
  ActivityNotification::Notification Load (39.4ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_id" = $1 AND "notifications"."target_type" = $2 AND "notifications"."opened_at" IS NULL AND "notifications"."group_owner_id" IS NULL ORDER BY "notifications"."created_at" DESC  [["target_id", 3], ["target_type", "User"]]
  ActivityNotification::Notification Load (1.5ms)  SELECT  "notifications".* FROM "notifications" WHERE "notifications"."target_id" = $1 AND "notifications"."target_type" = $2 AND ("notifications"."opened_at" IS NOT NULL) AND "notifications"."group_owner_id" IS NULL ORDER BY "notifications"."created_at" DESC LIMIT $3  [["target_id", 3], ["target_type", "User"], ["LIMIT", 10]]
  Rendering activity_notification/notifications/users/index.html.erb within layouts/application
  CACHE ActivityNotification::Notification Load (0.5ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_id" = $1 AND "notifications"."target_type" = $2 AND "notifications"."opened_at" IS NULL AND "notifications"."group_owner_id" IS NULL ORDER BY "notifications"."created_at" DESC  [["target_id", 3], ["target_type", "User"]]
  CACHE ActivityNotification::Notification Load (0.0ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_id" = $1 AND "notifications"."target_type" = $2 AND "notifications"."opened_at" IS NULL AND "notifications"."group_owner_id" IS NULL ORDER BY "notifications"."created_at" DESC  [["target_id", 3], ["target_type", "User"]]
  Rendered activity_notification/notifications/users/index.html.erb within layouts/application (34.8ms)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.