Appease the dog overlords

This commit is contained in:
Andreas Nedbal 2022-12-27 22:41:07 +01:00 committed by Andreas Nedbal
parent 37f4b78f66
commit 44e144cecc

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ShareWorker class ShareWorker
include Sidekiq::Worker include Sidekiq::Worker
@ -14,19 +16,19 @@ class ShareWorker
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
logger.info "Tried to post answer ##{answer_id} for user ##{user_id} to #{service.titleize} but the user/answer/service did not exist (likely deleted), will not retry." logger.info "Tried to post answer ##{answer_id} for user ##{user_id} to #{service.titleize} but the user/answer/service did not exist (likely deleted), will not retry."
# The question to be posted was deleted # The question to be posted was deleted
return nil
rescue Twitter::Error::DuplicateStatus rescue Twitter::Error::DuplicateStatus
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the status was already posted." logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the status was already posted."
return nil
rescue Twitter::Error::Forbidden rescue Twitter::Error::Forbidden
# User's Twitter account is suspended # User's Twitter account is suspended
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the account is suspended." logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the account is suspended."
return nil
rescue Twitter::Error::Unauthorized rescue Twitter::Error::Unauthorized
# User's Twitter token has expired or been revoked # User's Twitter token has expired or been revoked
# TODO: Notify user if this happens (https://github.com/Retrospring/retrospring/issues/123) # TODO: Notify user if this happens (https://github.com/Retrospring/retrospring/issues/123)
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the token has exired or been revoked." logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the token has exired or been revoked."
return nil
rescue => e rescue => e
logger.info "failed to post answer #{answer_id} to #{service} for user #{user_id}: #{e.message}" logger.info "failed to post answer #{answer_id} to #{service} for user #{user_id}: #{e.message}"
Sentry.capture_exception(e) Sentry.capture_exception(e)