File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 88GMAIL_USERNAME = ENV [ 'GMAIL_USERNAME' ]
99GMAIL_PASSWORD = ENV [ 'GMAIL_PASSWORD' ]
1010
11- gmail = Gmail . connect ( GMAIL_USERNAME , GMAIL_PASSWORD )
12- kumars_email = '[email protected] ' 11+ GMAIL = Gmail . connect ( GMAIL_USERNAME , GMAIL_PASSWORD )
12+ KUMARS_EMAIL = '[email protected] ' 1313
1414DB_NAME_REGEX = /\S +_staging/
1515KEYWORDS_REGEX = /sorry|help|wrong/i
1616
1717def create_reply ( subject )
18- gmail . compose do
19- to kumars_email
18+ GMAIL . compose do
19+ to KUMARS_EMAIL
2020 subject "RE: #{ subject } "
2121 body "No problem. I've fixed it. \n \n Please be careful next time."
2222 end
2323end
2424
25- gmail . inbox . find ( :unread , from : kumars_email ) . each do |email |
25+ GMAIL . inbox . find ( :unread , from : KUMARS_EMAIL ) . each do |email |
2626 if email . body . raw_source [ KEYWORDS_REGEX ] && ( db_name = email . body . raw_source [ DB_NAME_REGEX ] )
2727 backup_file = "/home/backups/databases/#{ db_name } -" + ( Date . today - 1 ) . strftime ( '%Y%m%d' ) + '.gz'
2828 abort 'ERROR: Backup file not found' unless File . exist? ( backup_file )
@@ -34,6 +34,6 @@ def create_reply(subject)
3434 email . read!
3535 email . label ( 'Database fixes' )
3636 reply = create_reply ( email . subject )
37- gmail . deliver ( reply )
37+ GMAIL . deliver ( reply )
3838 end
3939end
You can’t perform that action at this time.
0 commit comments