-
-
Save rob-race/9ea050fb46cc35f265acbe05be09afd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Get a user hash_id from reply-to or bail | |
reply_user = email.to.first[:token]&.split('<')&.last&.split('@')&.first&. | |
split('.')&.last | |
return if reply_user.blank? | |
# Find a user by the hash_id or bail | |
user = User.find_by(hash_id: reply_user) | |
return if user.nil? | |
# Bail if standup with incoming message-id exists | |
return if Standup.exists?(message_id: email.headers["Message-ID"]) | |
# Bail if a standup for today exists | |
today = Date.today.iso8601 | |
return if Standup.exists?(user_id: user.id, standup_date: today) | |
# Get content or bail | |
safe_body = Rails::Html::WhiteListSanitizer.new.sanitize(email.body) | |
tasks_from_body = safe_body.scan(/(\[[dtb]{1}\].*)$/) | |
return if tasks_from_body.blank? || tasks_from_body.empty? | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment