-
Notifications
You must be signed in to change notification settings - Fork 79
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
Notifications are reversed #88
Comments
Thank you for your feedback! I will check it in Dummy Rails application including gem. Does anybody have the same issue? Or does anybody successfully make these configuration? (notification between one models / |
@simukappu I added the following to acts_as_notifiable :users,
targets: -> (uer, key) {
User.all
},
tracked: { only: [:create] } I then create a new user through rails console 2.5.0 :004 > User.create(email: 'foo@bar.com')
(0.1ms) begin transaction
User Create (0.5ms) INSERT INTO "users" ("email", "confirmation_token", "confirmation_sent_at", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["email", "foo@bar.com"], ["confirmation_token", "dMcVdGtxbzp29wGa3BWP"], ["confirmation_sent_at", "2018-11-14 00:36:16.206725"], ["created_at", "2018-11-14 00:36:16.206592"], ["updated_at", "2018-11-14 00:36:16.206592"]]
User Load (0.1ms) SELECT "users".* FROM "users"
ActivityNotification::Subscription Load (0.1ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (0.1ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.4ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 1], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.214351"], ["updated_at", "2018-11-14 00:36:16.214351"]]
ActivityNotification::Subscription Load (0.1ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (0.2ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.1ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 2], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.219487"], ["updated_at", "2018-11-14 00:36:16.219487"]]
ActivityNotification::Subscription Load (0.1ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (0.2ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.2ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 3], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.224960"], ["updated_at", "2018-11-14 00:36:16.224960"]]
ActivityNotification::Subscription Load (0.1ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (0.2ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.2ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 4], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.231452"], ["updated_at", "2018-11-14 00:36:16.231452"]]
ActivityNotification::Subscription Load (0.1ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (0.1ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.2ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 5], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.237322"], ["updated_at", "2018-11-14 00:36:16.237322"]]
ActivityNotification::Subscription Load (0.4ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."target_id" = ? AND "subscriptions"."target_type" = ? AND "subscriptions"."key" = ? ORDER BY "subscriptions"."id" ASC LIMIT ? [["target_id", 6], ["target_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Load (1.4ms) SELECT "notifications".* FROM "notifications" WHERE "notifications"."target_type" = ? AND "notifications"."target_id" = ? AND "notifications"."notifiable_type" = ? AND "notifications"."key" = ? AND "notifications"."group_id" IS NULL AND "notifications"."group_owner_id" IS NULL AND "notifications"."opened_at" IS NULL ORDER BY "notifications"."created_at" ASC LIMIT ? [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["key", "user.create"], ["LIMIT", 1]]
ActivityNotification::Notification Create (0.7ms) INSERT INTO "notifications" ("target_type", "target_id", "notifiable_type", "notifiable_id", "key", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["target_type", "User"], ["target_id", 6], ["notifiable_type", "User"], ["notifiable_id", 6], ["key", "user.create"], ["created_at", "2018-11-14 00:36:16.274179"], ["updated_at", "2018-11-14 00:36:16.274179"]]
(2.6ms) commit transaction It created a notification for each user, however the target was the new user instead of the existing ones. Screen shot of the new user's notifications Edit: I updated the model to |
Hi @szechyjs, |
Seems to be working correctly now 👍 |
I have Just released this update as v1.6.1. Thank you for your contribution! |
…on_of to avoid ambiguous method name with Notifiable#notify_to - #88
It seems that all my notifications are being sent in the wrong direction.
In this case when I
member.save
I get the following error...From tracing it seems it is trying to send to the Member record instead of the Users.
Users -> Member
when it should beMember -> Users
I'm seeing similar behavior sending sending User -> User notifications as documented in my comment in issue #51 (comment)
The text was updated successfully, but these errors were encountered: