|
@@ -7,6 +7,7 @@ use App\Models\Sentence;
|
|
|
use App\Models\WebHook;
|
|
use App\Models\WebHook;
|
|
|
use App\Models\Discussion;
|
|
use App\Models\Discussion;
|
|
|
use App\Http\Api\Mq;
|
|
use App\Http\Api\Mq;
|
|
|
|
|
+use App\Tools\WebHook as WebHookSend;
|
|
|
|
|
|
|
|
class MqDiscussion extends Command
|
|
class MqDiscussion extends Command
|
|
|
{
|
|
{
|
|
@@ -52,17 +53,18 @@ class MqDiscussion extends Command
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
/**生成消息内容 */
|
|
/**生成消息内容 */
|
|
|
- $msgTitle = $message->editor->nickName;
|
|
|
|
|
|
|
+ $msgTitle = '**'. $message->editor->nickName.'**';
|
|
|
if($message->parent){
|
|
if($message->parent){
|
|
|
$parentTitle = Discussion::where('id',$message->parent)->value('title');
|
|
$parentTitle = Discussion::where('id',$message->parent)->value('title');
|
|
|
- $msgTitle .= '回复了 '.$parentTitle;
|
|
|
|
|
|
|
+ $link = "https://staging.wikipali.org/pcd/discussion/topic/{$message->parent}";
|
|
|
|
|
+ $msgTitle .= "回复了 [{$parentTitle}]({$link})";
|
|
|
}else{
|
|
}else{
|
|
|
- $msgTitle .= '创建了讨论 ';
|
|
|
|
|
|
|
+ $msgTitle .= "创建了讨论[$message->title]({$link})";
|
|
|
}
|
|
}
|
|
|
$msgContent = $msgTitle;
|
|
$msgContent = $msgTitle;
|
|
|
|
|
|
|
|
if($message->content){
|
|
if($message->content){
|
|
|
- $msgContent .= $message->content;
|
|
|
|
|
|
|
+ $msgContent .= "\n>".$message->content;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$webhooks = WebHook::where('res_id',$sentence->channel_uid)
|
|
$webhooks = WebHook::where('res_id',$sentence->channel_uid)
|
|
@@ -74,21 +76,19 @@ class MqDiscussion extends Command
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
$command = '';
|
|
$command = '';
|
|
|
|
|
+ $whSend = new WebHookSend;
|
|
|
|
|
+
|
|
|
switch ($hook->receiver) {
|
|
switch ($hook->receiver) {
|
|
|
case 'dingtalk':
|
|
case 'dingtalk':
|
|
|
- $command = 'webhook:dingtalk';
|
|
|
|
|
|
|
+ $ok = $whSend->dingtalk($hook->url,null,$msgContent);
|
|
|
break;
|
|
break;
|
|
|
case 'wechat':
|
|
case 'wechat':
|
|
|
- $command = 'webhook:wechat';
|
|
|
|
|
|
|
+ $ok = $whSend->wechat($hook->url,null,$msgContent);
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
- # code...
|
|
|
|
|
|
|
+ $ok=2;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- $ok = $this->call($command,['url'=>$hook->url,
|
|
|
|
|
- 'title'=>"title",
|
|
|
|
|
- 'message'=>$msgContent,
|
|
|
|
|
- ]);
|
|
|
|
|
$this->info("{$command} ok={$ok}");
|
|
$this->info("{$command} ok={$ok}");
|
|
|
if($ok===0){
|
|
if($ok===0){
|
|
|
WebHook::where('id',$hook->id)->increment('success');
|
|
WebHook::where('id',$hook->id)->increment('success');
|