From 634745409819d479b5d10b7b1f9ff66653633756 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 17 May 2022 19:55:47 +0800 Subject: [PATCH] no message --- app/Models/WebSocketDialog.php | 17 ++++++++++------- app/Tasks/EmailNoticeTask.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 4c158d67f..57ac80b0a 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -185,15 +185,18 @@ class WebSocketDialog extends AbstractModel */ public function getGroupName() { - $name = $this->name; - if ($this->type == "group") { - if ($this->group_type === 'project') { - $name = \DB::table('projects')->where('dialog_id', $this->id)->value('name'); - } elseif ($this->group_type === 'task') { - $name = \DB::table('project_tasks')->where('dialog_id', $this->id)->value('name'); + if (!isset($this->appendattrs['groupName'])) { + $name = $this->name; + if ($this->type == "group") { + if ($this->group_type === 'project') { + $name = \DB::table('projects')->where('dialog_id', $this->id)->value('name'); + } elseif ($this->group_type === 'task') { + $name = \DB::table('project_tasks')->where('dialog_id', $this->id)->value('name'); + } } + $this->appendattrs['groupName'] = $name; } - return $name; + return $this->appendattrs['groupName']; } /** diff --git a/app/Tasks/EmailNoticeTask.php b/app/Tasks/EmailNoticeTask.php index 41345c3e4..bf5ec150a 100644 --- a/app/Tasks/EmailNoticeTask.php +++ b/app/Tasks/EmailNoticeTask.php @@ -195,8 +195,8 @@ class EmailNoticeTask extends AbstractTask continue; } $setting = Base::setting('emailSetting'); - $msgType = $dialogType === "group" ? "群聊" : "个人"; - $subject = env('APP_NAME') . " 未读{$msgType}消息提醒"; + $msgType = $dialogType === "group" ? "群聊" : "成员"; + $subject = null; $content = view('email.unread', [ 'type' => 'head', 'nickname' => $user->nickname, @@ -227,6 +227,14 @@ class EmailNoticeTask extends AbstractTask } } } + if ($subject === null) { + $count = count($lists); + if ($count > 1) { + $subject = "来自{$count}个{$msgType}未读消息提醒"; + } else { + $subject = "来自{$dialogName}未读消息提醒"; + } + } $content .= view('email.unread', [ 'type' => 'content', 'dialogUrl' => config("app.url") . "/manage/messenger/{$dialogId}",