docbrown/app/services/notifications
Daniel Uber 293ff5653a
Fix integer > nil error when sending reaction notifications (#16627)
* don't set nil when size not called

recently, #16570 worked around an issue where aggregated siblings
wasn't present, by only calling size if present.

Unfortunately, this causes a comparison of integer (new json_data
aggregated siblings count) with nil (result of the safe navigation for dig()&.size
assigned nil to previous_siblings_size, when we expected it to be
0). The initial error on the same data moved farther down the controller.

If old_json_data is present, but does not have an array in
reaction.aggregated_siblings, we want to have previous size be zero.

Remove guard clause and previous assignment

The issue was not that old_json_data was nil (it came from an existing
notification) but that there were missing keys (or rather that the
json data for some notifications didn't have a reaction key at all).

Remove the guard clause and either set to the size, or zero if there
is none. I don't understand what the guard clause was for, so replace the
safety by adding a nil safe call to dig. I don't _believe_ this is
possible but in case it was we can shorten the check here.

* Add test to cover missing json_data['reaction'] key

* Remove unneeded temporary variable
2022-02-17 16:30:39 -06:00
..
milestone Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
moderation Rename User.dev_account to User.staff_account (#14321) 2021-07-26 10:46:26 -04:00
new_badge_achievement Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
new_comment app/services i18n (#16189) 2022-01-20 09:25:25 -05:00
new_follower Ensure arguments to perform_async are json safe (#16285) 2022-01-25 18:07:40 -06:00
new_mention app/services i18n (#16189) 2022-01-20 09:25:25 -05:00
notifiable_action Don't notify authors about own org posts (#15113) 2021-10-19 21:32:44 +07:00
reactions Fix integer > nil error when sending reaction notifications (#16627) 2022-02-17 16:30:39 -06:00
tag_adjustment_notification Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
welcome_notification Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
moderation.rb Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121) 2021-07-08 09:31:34 -05:00
remove_all.rb Fix notifications not deleting because mentions already destroyed (#14987) 2021-10-14 09:41:10 -06:00
remove_all_by_action.rb Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
update.rb Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00