mail robot for application email monitor mailbox check new added email file in new check new mail's subject return if unmatched subject call answerback-email apply account apply uuid write account/uuid etc. to es send uuid to user
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- container/mail-robot/mail-robot.rb | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 container/mail-robot/mail-robot.rb
diff --git a/container/mail-robot/mail-robot.rb b/container/mail-robot/mail-robot.rb new file mode 100755 index 0000000..f91b89d --- /dev/null +++ b/container/mail-robot/mail-robot.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# frozen_string_literal: true + +require 'json' +require 'yaml' +require 'listen' +require 'mail' +require 'fileutils' +require_relative 'answerback-email.rb' + +mail_inbox = '/Maildir/.compass-ci/new/' +mail_drafts = '/Maildir/.compass-ci/cur/' + +def monitor_dir(mail_inbox, mail_drafts) + listener = Listen.to(mail_inbox) do |modified, added, _removed| + unless added.empty? + added.each do |mail_file| + begin + check_to_send_account(mail_file, mail_drafts) + rescue StandardError => e + puts e.message + end + end + end + end + listener.start + sleep +end + +def check_to_send_account(mail_file, mail_drafts) + mail_content = Mail.read(mail_file) + subject = mail_content.subject + return unless subject =~ /apply account/i + + send_account(mail_content) + FileUtils.mv(mail_file, mail_drafts) +end + +monitor_dir(mail_inbox, mail_drafts)
Signed-off-by: Luan Shengde luanshengde2@huawei.com
+ Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
Thanks, Yinsi
On Fri, Oct 09, 2020 at 03:56:31PM +0800, Liu Yinsi wrote:
Signed-off-by: Luan Shengde luanshengde2@huawei.com
+ Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
is this needed after per license line?
Thanks Luan Shengde
Thanks, Yinsi
On Sat, Oct 10, 2020 at 09:10:10AM +0800, Luan Shengde wrote:
On Fri, Oct 09, 2020 at 03:56:31PM +0800, Liu Yinsi wrote:
Signed-off-by: Luan Shengde luanshengde2@huawei.com
+ Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
is this needed after per license line?
Yes, the copyright requirement is added later on.
Thanks, Fengguang
On Sat, Oct 10, 2020 at 10:46:44AM +0800, Wu Fengguang wrote:
On Sat, Oct 10, 2020 at 09:10:10AM +0800, Luan Shengde wrote:
On Fri, Oct 09, 2020 at 03:56:31PM +0800, Liu Yinsi wrote:
Signed-off-by: Luan Shengde luanshengde2@huawei.com
+ Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
is this needed after per license line?
Yes, the copyright requirement is added later on.
I got it.
Thanks Luan Shengde
Thanks, Fengguang