On Tue, Nov 17, 2020 at 10:11:32AM +0800, Liu Yinsi wrote:
- added.each do |mail_file|
handle_new_email(mail_file, mail_drafts)
- end
added.each { |mail_file| handle_new_email(mail_file, mail_drafts) }
it can omit 'do/end'.
yes it can be write like this, but not good for reading
Thanks, Luan Shengde
Thanks, Yinsi
- end
- listener.start
- sleep
+end
+def handle_new_email(mail_file, mail_drafts)
- mail_content = Mail.read(mail_file)
- apply_account(mail_content)
- FileUtils.mv(mail_file, mail_drafts)
+end
+def apply_account(mail_content)
- return unless mail_content.subject == 'apply account'
- assign_uuid = ApplyAccount.new(mail_content)
- assign_uuid.check_to_send_account
+end
+monitor_new_email("#{MAILDIR}/new", "#{MAILDIR}/cur")
2.23.0