WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 01feacf

Browse files
committed
no message
1 parent d6ddc5f commit 01feacf

File tree

29 files changed

+180
-116
lines changed

29 files changed

+180
-116
lines changed

app/Http/Controllers/Api/ApproveController.php

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,30 +1008,26 @@ public function approveMsg($type, $dialog, $botUser, $toUser, $process, $action
10081008
$msgAction = 'change-' . $toUser['msg_id'];
10091009
}
10101010
//
1011-
try {
1012-
$msg = WebSocketDialogMsg::sendMsg($msgAction, $dialog->id, 'template', $msgData, $process['start_user_id'], false, false, true);
1013-
// 关联信息
1014-
if ($action == 'start') {
1015-
$proc_msg = new ApproveProcMsg();
1016-
$proc_msg->proc_inst_id = $process['id'];
1017-
$proc_msg->msg_id = $msg['data']->id;
1018-
$proc_msg->userid = $toUser['userid'];
1019-
$proc_msg->save();
1020-
}
1021-
// 更新审批 未读数量
1022-
if ($type == 'approve_reviewer' && $toUser['userid']) {
1023-
$params = [
1024-
'userid' => [$toUser['userid'], User::auth()->userid()],
1025-
'msg' => [
1026-
'type' => 'approve',
1027-
'action' => 'unread',
1028-
'userid' => $toUser['userid'],
1029-
]
1030-
];
1031-
Task::deliver(new PushTask($params, false));
1032-
}
1033-
} catch (\Throwable $th) {
1034-
info($th->getMessage());
1011+
$msg = WebSocketDialogMsg::sendMsg($msgAction, $dialog->id, 'template', $msgData, $process['start_user_id'], false, false, true);
1012+
// 关联信息
1013+
if ($action == 'start') {
1014+
$proc_msg = new ApproveProcMsg();
1015+
$proc_msg->proc_inst_id = $process['id'];
1016+
$proc_msg->msg_id = $msg['data']->id;
1017+
$proc_msg->userid = $toUser['userid'];
1018+
$proc_msg->save();
1019+
}
1020+
// 更新审批 未读数量
1021+
if ($type == 'approve_reviewer' && $toUser['userid']) {
1022+
$params = [
1023+
'userid' => [$toUser['userid'], User::auth()->userid()],
1024+
'msg' => [
1025+
'type' => 'approve',
1026+
'action' => 'unread',
1027+
'userid' => $toUser['userid'],
1028+
]
1029+
];
1030+
Task::deliver(new PushTask($params, false));
10351031
}
10361032
return true;
10371033
}

app/Http/Controllers/Api/DialogController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ public function msg__stream()
985985
*
986986
* @apiParam {Number} dialog_id 对话ID
987987
* @apiParam {String} text 消息内容
988+
* @apiParam {String} [key] 搜索关键词 (不设置根据内容自动生成)
988989
* @apiParam {String} [text_type] 消息类型
989990
* - html: HTML(默认)
990991
* - md: MARKDOWN
@@ -1012,6 +1013,7 @@ public function msg__sendtext()
10121013
$update_mark = !($user->bot && in_array(strtolower(trim(Request::input('update_mark'))), ['no', 'false', '0']));
10131014
$reply_id = intval(Request::input('reply_id'));
10141015
$text = trim(Request::input('text'));
1016+
$key = trim(Request::input('key'));
10151017
$text_type = strtolower(trim(Request::input('text_type')));
10161018
$silence = in_array(strtolower(trim(Request::input('silence'))), ['yes', 'true', '1']);
10171019
$markdown = in_array($text_type, ['md', 'markdown']);
@@ -1064,13 +1066,16 @@ public function msg__sendtext()
10641066
'height' => -1,
10651067
'ext' => $ext,
10661068
];
1067-
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence);
1069+
if (empty($key)) {
1070+
$key = mb_substr(strip_tags($text), 0, 200);
1071+
}
1072+
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid, false, false, $silence, $key);
10681073
} else {
10691074
$msgData = ['text' => $text];
10701075
if ($markdown) {
10711076
$msgData['type'] = 'md';
10721077
}
1073-
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence);
1078+
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence, $key);
10741079
}
10751080
}
10761081
return $result;

app/Models/WebSocketDialogMsg.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -640,27 +640,35 @@ private function previewTemplateMsg($msg)
640640

641641
/**
642642
* 生成关键词并保存
643+
* @param string $key
643644
* @return void
644645
*/
645-
public function generateKeyAndSave(): void
646+
public function generateKeyAndSave(string $key = ''): void
646647
{
647-
$key = '';
648-
switch ($this->type) {
649-
case 'text':
650-
case 'vote':
651-
case 'word-chain':
652-
$key = strip_tags($this->msg['text']);
653-
break;
648+
if (empty($key)) {
649+
$key = '';
650+
switch ($this->type) {
651+
case 'text':
652+
if (!preg_match("/<span[^>]*?data-quick-key=([\"'])(.*?)\\1[^>]*?>/is", $this->msg['text'])) {
653+
$key = strip_tags($this->msg['text']);
654+
}
655+
break;
654656

655-
case 'file':
656-
$key = $this->msg['name'];
657-
$key = preg_replace("/^(image|\d+)\.(png|jpg|jpeg|webp|gif)$/i", "", $key);
658-
$key = preg_replace("/^LongText-(.*?)/i", "", $key);
659-
break;
657+
case 'vote':
658+
case 'word-chain':
659+
$key = strip_tags($this->msg['text']);
660+
break;
660661

661-
case 'meeting':
662-
$key = $this->msg['name'];
663-
break;
662+
case 'file':
663+
$key = $this->msg['name'];
664+
$key = preg_replace("/^(image|\d+)\.(png|jpg|jpeg|webp|gif)$/i", "", $key);
665+
$key = preg_replace("/^LongText-(.*?)/i", "", $key);
666+
break;
667+
668+
case 'meeting':
669+
$key = $this->msg['name'];
670+
break;
671+
}
664672
}
665673
$key = str_replace(["&quot;", "&amp;", "&lt;", "&gt;"], "", $key);
666674
$key = str_replace(["\r", "\n", "\t", "&nbsp;"], " ", $key);
@@ -940,9 +948,10 @@ public static function formatMsg($text, $dialog_id)
940948
* @param bool $push_retry 推送-失败后重试1次(有时候在事务里执行,数据还没生成时会出现找不到消息的情况)
941949
* @param bool|null $push_silence 推送-静默
942950
* - type = [text|file|record|meeting] 默认为:false
951+
* @param string|null $search_key 搜索关键词(用于搜索,留空则自动生成)
943952
* @return array
944953
*/
945-
public static function sendMsg($action, $dialog_id, $type, $msg, $sender = null, $push_self = false, $push_retry = false, $push_silence = null)
954+
public static function sendMsg($action, $dialog_id, $type, $msg, $sender = null, $push_self = false, $push_retry = false, $push_silence = null, $search_key = null)
946955
{
947956
$link = 0;
948957
$mtype = $type;
@@ -1017,7 +1026,7 @@ public static function sendMsg($action, $dialog_id, $type, $msg, $sender = null,
10171026
'modify' => $modify,
10181027
];
10191028
$dialogMsg->updateInstance($updateData);
1020-
$dialogMsg->generateKeyAndSave();
1029+
$dialogMsg->generateKeyAndSave($search_key);
10211030
//
10221031
WebSocketDialogUser::whereDialogId($dialog->id)->whereUserid($sender)->whereHide(1)->change([
10231032
'hide' => 0, // 修改消息时,显示会话(仅自己)
@@ -1064,7 +1073,7 @@ public static function sendMsg($action, $dialog_id, $type, $msg, $sender = null,
10641073
]);
10651074
AbstractModel::transaction(function () use ($dialogMsg) {
10661075
$dialogMsg->send = 1;
1067-
$dialogMsg->generateKeyAndSave();
1076+
$dialogMsg->generateKeyAndSave($search_key);
10681077
//
10691078
if ($dialogMsg->type === 'meeting') {
10701079
MeetingMsg::createInstance([

app/Tasks/BotReceiveMsgTask.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,19 @@ private function botManagerWebhook(string $command, WebSocketDialogMsg $msg, Use
526526
$userBot->webhook_num++;
527527
$userBot->save();
528528
}
529-
if ($res['data'] && $data = json_decode($res['data'])) {
529+
if ($res['data'] && $data = Base::json2array($res['data'])) {
530530
if ($data['code'] != 200 && $data['message']) {
531531
WebSocketDialogMsg::sendMsg(null, $msg->dialog_id, 'text', ['text' => $res['data']['message']], $botUser->userid, false, false, true);
532532
}
533533
}
534534
} catch (\Throwable $th) {
535-
info($th->getMessage());
535+
info(Base::array2json([
536+
'bot_userid' => $botUser->userid,
537+
'dialog' => $dialog->id,
538+
'msg' => $msg->id,
539+
'webhook_url' => $webhookUrl,
540+
'error' => $th->getMessage(),
541+
]));
536542
}
537543
}
538544

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use App\Models\WebSocketDialog;
4+
use App\Models\WebSocketDialogMsg;
5+
use App\Models\WebSocketDialogMsgRead;
6+
use Illuminate\Database\Migrations\Migration;
7+
use Illuminate\Database\Schema\Blueprint;
8+
use Illuminate\Support\Facades\Schema;
9+
10+
class AddWebSocketDialogMsgReadsLive2 extends Migration
11+
{
12+
/**
13+
* Run the migrations.
14+
*
15+
* @return void
16+
*/
17+
public function up()
18+
{
19+
WebSocketDialogMsg::whereType('text')->where('key', 'like', "LongText-%")->update(['key' => '']);
20+
WebSocketDialogMsg::whereType('file')->where('key', 'like', "image.%")->update(['key' => '']);
21+
22+
}
23+
24+
/**
25+
* Reverse the migrations.
26+
*
27+
* @return void
28+
*/
29+
public function down()
30+
{
31+
//
32+
}
33+
}

language/original-api.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@ webhook地址最长仅支持255个字符。
528528
操作频繁!
529529
暂未开启签到功能。
530530
暂未开放手动签到。
531-
上班打卡成功,打卡时间:(*)(手动签到)
532531
上班打卡成功,打卡时间:(*)
533-
下班打卡成功,打卡时间:(*)(手动签到)
534532
下班打卡成功,打卡时间:(*)
533+
今日已上班打卡,无需重复打卡。(*)
534+
今日已下班打卡,无需重复打卡。(*)
535535
今日已上班打卡,无需重复打卡。
536536
今日已下班打卡,无需重复打卡。
537537
上班时间到了,你还没有打卡哦~

language/original-web.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
错误的类型参数
199199
项目未完成任务
200200
上传/浏览 图片
201-
签到设置 (Beta)
202201
不能对话自己
203202
任务完成时间
204203
修改任务时间
@@ -1624,10 +1623,10 @@ Token
16241623
操作频繁!
16251624
暂未开启签到功能。
16261625
暂未开放手动签到。
1627-
上班打卡成功,打卡时间:(*)(手动签到)
16281626
上班打卡成功,打卡时间:(*)
1629-
下班打卡成功,打卡时间:(*)(手动签到)
16301627
下班打卡成功,打卡时间:(*)
1628+
今日已上班打卡,无需重复打卡。(*)
1629+
今日已下班打卡,无需重复打卡。(*)
16311630
今日已上班打卡,无需重复打卡。
16321631
今日已下班打卡,无需重复打卡。
16331632
缺卡提醒
@@ -1696,3 +1695,6 @@ WiFi签到延迟时长为±1分钟。
16961695

16971696
群内成员
16981697
群外成员
1698+
1699+
该任务尚未被领取,点击这里
1700+
搜索词 (留空自动生成)

0 commit comments

Comments
 (0)