Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriptions key validation #126

Closed
Eth3rnit3 opened this issue Feb 19, 2020 · 7 comments
Closed

subscriptions key validation #126

Eth3rnit3 opened this issue Feb 19, 2020 · 7 comments

Comments

@Eth3rnit3
Copy link
Contributor

Eth3rnit3 commented Feb 19, 2020

Hello, first of all, I wanted to impregnate you for the work you've done. I just implemented this gem in a very big application, even if it took me 2 days, thanks to you, I gained a lot more!

I was able to easily implement slack as well as other notification thanks to base and everything works very well.

There's still something I don't understand or that I had to do wrong, but I don't understand why when a user save his subscription for a given key for example message.reply then no other user can subscribe to this key, and those because of this validation

validates :key, presence: true, uniqueness: { scope: :target }

pry(main)> a.find_or_create_subscription('message.reply').subscribe
=> true

pry(main)> b.find_or_create_subscription('message.reply').subscribe
ActivityNotification::RecordInvalidError: Key est déjà pris.
from /Users/eth3rnit3/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activity_notification-2.1.1/lib/activity_notification/models/concerns/subscriber.rb:53:in `create_subscription'

I think that each user can subscribe to the same key no?

@sebfie
Copy link

sebfie commented Feb 20, 2020

@simukappu I also have this issue !

@Eth3rnit3
Copy link
Contributor Author

Eth3rnit3 commented Feb 20, 2020

I can give you more information about the problem...
it's probably related to mongoid

I can solve my problem by replacing the :target of this line

validates :key, presence: true, uniqueness: { scope: :target }

by :target_id

@simukappu
Copy link
Owner

I've recognized this mongoid subscription bug from v2.1.0. Thank you for your feedback!

@Eth3rnit3
Copy link
Contributor Author

gladly

@simukappu
Copy link
Owner

Confirmed and merged your pull request #128. Thank you!

@Eth3rnit3
Copy link
Contributor Author

Thank you!

@simukappu
Copy link
Owner

Just released as v2.1.2. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants