From ff1625708e564fdbde2576c6f704df35f99be62f Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Fri, 3 Sep 2021 13:45:14 +0530 Subject: [PATCH] fix: Subscription attribute update issue (#2951) --- app/builders/notification_subscription_builder.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/builders/notification_subscription_builder.rb b/app/builders/notification_subscription_builder.rb index c1574bfc1..af75ef2fd 100644 --- a/app/builders/notification_subscription_builder.rb +++ b/app/builders/notification_subscription_builder.rb @@ -4,7 +4,7 @@ class NotificationSubscriptionBuilder def perform # if multiple accounts were used to login in same browser move_subscription_to_user if identifier_subscription && identifier_subscription.user_id != user.id - build_identifier_subscription if identifier_subscription.blank? + identifier_subscription.blank? ? build_identifier_subscription : update_identifier_subscription identifier_subscription end @@ -25,6 +25,10 @@ class NotificationSubscriptionBuilder end def build_identifier_subscription - user.notification_subscriptions.create(params.merge(identifier: identifier)) + @identifier_subscription = user.notification_subscriptions.create(params.merge(identifier: identifier)) + end + + def update_identifier_subscription + identifier_subscription.update(params.merge(identifier: identifier)) end end