From b2d9f4dbbcf69402f3f730ca8f3e5faa4c40e0a0 Mon Sep 17 00:00:00 2001 From: vilson <545522390@qq.com> Date: Fri, 13 Sep 2019 09:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: vilson <545522390@qq.com> --- application/common.php | 8 ++++++++ application/project/behavior/Task.php | 24 ++++++++++++++++++++++-- config/config.php | 3 ++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/application/common.php b/application/common.php index 5233bf4..42ecc1b 100644 --- a/application/common.php +++ b/application/common.php @@ -187,6 +187,14 @@ function isOpenDingTalkNoticePush() { return config('config.dingtalk_push'); } +/** + * 是否开启钉钉消息推送 + * @return mixed + */ +function isOpenMailNoticePush() +{ + return config('config.mail_push'); +} /** * 日期格式标准输出 diff --git a/application/project/behavior/Task.php b/application/project/behavior/Task.php index 4b82e97..0658375 100644 --- a/application/project/behavior/Task.php +++ b/application/project/behavior/Task.php @@ -9,7 +9,6 @@ namespace app\project\behavior; -use app\common\Model\CommonModel; use app\common\Model\Member; use app\common\Model\Notify; use app\common\Model\ProjectLog; @@ -17,13 +16,15 @@ use app\common\Model\ProjectVersion; use app\common\Model\TaskMember; use app\common\Model\TaskStages; use app\common\Model\TaskWorkflowRule; +use Exception; +use mail\Mail; use message\DingTalk; use service\MessageService; use think\Db; use think\db\exception\DataNotFoundException; use think\db\exception\ModelNotFoundException; use think\exception\DbException; -use think\facade\Log; +use think\facade\Request; class Task { @@ -279,6 +280,25 @@ class Task $messageDingTalk->sendCorporationMessage($member['dingtalk_userid'], $params); } } + if (isOpenMailNoticePush()) { + if (config('mail.open')) { + $mailer = new Mail(); + try { + $mail = $mailer->mail; + $mail->CharSet = 'utf-8'; + $mail->setFrom(config('mail.Username'), 'pearProject'); + $mail->addAddress($member['email'], $member['realname']); + //Content + $mail->isHTML(true); + $link = Request::domain() . '/#/project/space/task/' . $task['project_code']; + $mail->Subject = '[任务动态] ' . $notifyData['title']; + $mail->Body = "[任务] {$notifyData['content']} 点击查看项目"; + $mail->send(); + } catch (Exception $e) { + ob_clean(); + } + } + } if (isOpenNoticePush()) { $socketMessage['notify'] = $result; $messageService->sendToUid($taskMember['member_code'], $socketMessage, $socketAction); diff --git a/config/config.php b/config/config.php index 1067ffd..420179b 100644 --- a/config/config.php +++ b/config/config.php @@ -1,5 +1,6 @@ false, //是否开启websocket消息推送 + 'notice_push' => true, //是否开启websocket消息推送 'dingtalk_push' => false, //是否开启钉钉消息推送 + 'mail_push' => false, //是否开启邮件消息推送 ];