On Wed, Nov 04, 2020 at 08:16:05PM +0800, Liu Shaofei wrote:
On Wed, Nov 04, 2020 at 06:17:59PM +0800, Luan Shengde wrote:
check to assign account invoke ParseApplyAccountEmail to parse commit url and pubkey generate uuid and invoke AssignJumperAccount to apply account store account info to es send uuid
Signed-off-by: Luan Shengde shdluan@163.com
container/mail-robot/apply-account.rb | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 container/mail-robot/apply-account.rb
diff --git a/container/mail-robot/apply-account.rb b/container/mail-robot/apply-account.rb new file mode 100755 index 0000000..9a8d706 --- /dev/null +++ b/container/mail-robot/apply-account.rb @@ -0,0 +1,65 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'json' +require 'mail' +require_relative '../../lib/es_client'
+# assign uuid/account +class AssignAccount
- def initialize(mail_content)
- @mail_content = mail_content
- @my_email = mail_content.from[0]
- @my_name = mail_content.From.unparsed_value.gsub(/ <[^<>]*>/, '')
- @send_mail_host = %x(/sbin/ip route |awk '/default/ {print $3}').chomp
@mail_content = mail_content @my_email = mail_content.from[0] @my_name = mail_content.From.unparsed_value.gsub(/ <[^<>]*>/,'') please keep aligned, looks better.
I will align them
- end
- def check_to_send_account
- my_commit_url, my_ssh_pubkey = check_out_commit_url_pub_key
- my_uuid, acct_infos = check_to_apply_account(my_ssh_pubkey)
- my_info = {
'my_email' => @my_email,
'my_name' => @my_name,
'my_commit_url' => my_commit_url,
'my_login_name' => acct_infos['my_login_name'],
'my_uuid' => my_uuid
^----diito
in hash, the rubocob recommend one space.
- }
- store_account_info(my_info)
- my_info['acct_infos'] = acct_infos
- send_my_uuid(my_info)
- end
- def check_out_commit_url_pub_key
- parse_apply_account_email = ParseApplyAccountEmail.new(@mail_content)
- my_commit_url, my_ssh_pubkey = parse_apply_account_email.parse_commit_url_pub_key
- return my_commit_url, my_ssh_pubkey
- end
- def check_to_apply_account(my_ssh_pubkey)
- my_uuid = %x(uuidgen).chomp
- apply_account_info = {
'my_email' => @my_email,
'my_name' => @my_name,
'my_uuid' => my_uuid,
'my_ssh_pubkey' => my_ssh_pubkey
^----ditto
ditto
Thanks, Luan Shengde
Thanks, Liushaofei
- }
- apply_account = AssignJumperAccount.new(apply_account_info)
- acct_infos = apply_account.apply_jumper_account
- return my_uuid, acct_infos
- end
- def store_account_info(my_info)
- es = ESClient.new(index: 'accounts')
- es.put_source_by_id(my_info['my_email'], my_info)
- end
- def send_my_uuid(my_info)
- send_uuid = SendApplyAccountEmail.new(my_info)
- send_uuid.send_uuid_email
- end
+end
2.23.0