fix: 推送收到的群组名称为空的情况

This commit is contained in:
kuaifan 2022-05-14 22:11:57 +08:00
parent 3e19f3991c
commit 04bc5d7d17
2 changed files with 18 additions and 1 deletions

View File

@ -179,6 +179,23 @@ class WebSocketDialog extends AbstractModel
}
}
/**
* 获取群组名称
* @return mixed|string|null
*/
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');
}
}
return $name;
}
/**
* 推送消息
* @param $action

View File

@ -84,7 +84,7 @@ class WebSocketDialogMsgTask extends AbstractTask
// umeng推送app
$msgTitle = User::userid2nickname($msg->userid);
if ($dialog->type == 'group') {
$msgTitle = "{$dialog->name} ($msgTitle)";
$msgTitle = "{$dialog->getGroupName()} ($msgTitle)";
}
$umengMsg = new PushUmengMsg(array_keys($array), [
'title' => $msgTitle,