Signed-off-by: Luan Shengde luanshengde2@huawei.com --- container/send-mail/conf/sources.list | 9 ----- container/send-mail/mail-post.rb | 48 --------------------------- 2 files changed, 57 deletions(-) delete mode 100644 container/send-mail/conf/sources.list delete mode 100755 container/send-mail/mail-post.rb
diff --git a/container/send-mail/conf/sources.list b/container/send-mail/conf/sources.list deleted file mode 100644 index 8179e01..0000000 --- a/container/send-mail/conf/sources.list +++ /dev/null @@ -1,9 +0,0 @@ -deb [trusted=yes] http://mirrors.163.com/debian/ buster main non-free contrib -deb [trusted=yes] http://mirrors.163.com/debian/ buster-updates main non-free contrib -deb [trusted=yes] http://mirrors.163.com/debian/ buster-backports main non-free contrib -deb [trusted=yes] http://mirrors.163.com/debian-security/ buster/updates main non-free contrib - -deb-src [trusted=yes] http://mirrors.163.com/debian/ buster main non-free contrib -deb-src [trusted=yes] http://mirrors.163.com/debian/ buster-updates main non-free contrib -deb-src [trusted=yes] http://mirrors.163.com/debian/ buster-backports main non-free contrib -deb-src [trusted=yes] http://mirrors.163.com/debian-security/ buster/updates main non-free contrib diff --git a/container/send-mail/mail-post.rb b/container/send-mail/mail-post.rb deleted file mode 100755 index 4eecf6e..0000000 --- a/container/send-mail/mail-post.rb +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 'sinatra' -require 'json' -require 'yaml' -require 'open3' -require_relative 'send-mail.rb' - -set :bind, '0.0.0.0' -set :port, 11311 - -post '/send_mail_yaml' do - data = YAML.safe_load request.body.read - raise TypeError, data, 'request data type error' unless data.class.eql? Hash - - mail_info = { - 'references' => data['references'] || '', - 'from' => data['from'] || 'team@crystal.ci', - 'subject' => data['subject'], - 'to' => data['to'], - 'body' => data['body'] - } - check_send_mail(mail_info) -end - -post '/send_mail_text' do - data = Mail.read_from_string(request.body.read) - - mail_info = { - 'references' => data.references || '', - 'from' => data.from || 'team@crystal.ci', - 'subject' => data.subject, - 'to' => data.to, - 'body' => data.body.decoded - } - check_send_mail(mail_info) -end - -def check_send_mail(mail_info) - raise TypeError, data, 'empty subject.' if mail_info['subject'].empty? - raise TypeError, data, 'empty email address.' if mail_info['to'].empty? - raise TypeError, data, 'empty email content.' if mail_info['body'].empty? - - send_mail(mail_info) -end