From 21975a11fd00d0a67daafe958b553217c8ad896e Mon Sep 17 00:00:00 2001 From: Plastikmensch Date: Sun, 14 May 2023 23:53:57 +0200 Subject: [PATCH] Rescue uncaught RecordInvalid errors These occur when an account tries to react with disabled custom emojis. In both `EmojiReact` and `Like? activities, the activity is discarded. Signed-off-by: Plastikmensch --- app/lib/activitypub/activity/emoji_react.rb | 2 ++ app/lib/activitypub/activity/like.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/app/lib/activitypub/activity/emoji_react.rb b/app/lib/activitypub/activity/emoji_react.rb index 292ea6fd3..9f28064cc 100644 --- a/app/lib/activitypub/activity/emoji_react.rb +++ b/app/lib/activitypub/activity/emoji_react.rb @@ -22,5 +22,7 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji) LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction') + rescue ActiveRecord::RecordInvalid + nil end end diff --git a/app/lib/activitypub/activity/like.rb b/app/lib/activitypub/activity/like.rb index 37215c179..1ded77f4a 100644 --- a/app/lib/activitypub/activity/like.rb +++ b/app/lib/activitypub/activity/like.rb @@ -34,5 +34,8 @@ class ActivityPub::Activity::Like < ActivityPub::Activity reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji) LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction') true + # account tried to react with disabled custom emoji. Returning true to discard activity. + rescue ActiveRecord::RecordInvalid + true end end