Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
Bug Fix
  • Loading branch information
fonqing committed Jan 10, 2022
1 parent ae13086 commit f5f7b21
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/Notify/DingTalk.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aoma\Notify;
use Aoma\Notify;
use Aoma\Notify\Notify as NotifyInterface;
use Aoma\Notify\NotifyInterface;
use Exception;

class DingTalk extends Notify implements NotifyInterface {
Expand Down Expand Up @@ -63,8 +63,10 @@ public function send($type, $title, $msg, $to = [], $extra = [])
$content.= $name.': '.$value.PHP_EOL;
}
}
$to = is_array($to) ? $to : [$to];
$content .= '@'.implode(' @', $to).PHP_EOL;
if(!empty($to)){
$this->mention = is_array($to) ? $to : [$to];
}
$content .= '@'.implode(' @', $this->mention).PHP_EOL;
$content .= PHP_EOL;
$data = [
'msgtype' => 'markdown',
Expand All @@ -73,7 +75,7 @@ public function send($type, $title, $msg, $to = [], $extra = [])
'text' => $content
],
'at' => [
'atMobiles' => $to,
'atMobiles' => $this->mention,
'isAtAll' => false
]
];
Expand Down
8 changes: 5 additions & 3 deletions src/Notify/Feishu.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aoma\Notify;
use Aoma\Notify;
use Aoma\Notify\Notify as NotifyInterface;
use Aoma\Notify\NotifyInterface;
use Exception;

class Feishu extends Notify implements NotifyInterface {
Expand Down Expand Up @@ -62,8 +62,10 @@ public function send($type, $title, $msg, $to = [], $extra = [])
$content.= $name.': '.$value.PHP_EOL;
}
}
$to = is_array($to) ? $to : [$to];
foreach($to as $openid){
if(!empty($to)){
$this->mention = is_array($to) ? $to : [$to];
}
foreach($this->mention as $openid){
$content.='<at user_id="'.$openid.'">相关接收人</at>'.PHP_EOL;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aoma\Notify;

interface Notify {
interface NotifyInterface {

/**
* Send message
Expand Down
9 changes: 6 additions & 3 deletions src/Notify/WxWork.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Aoma\Notify;
use Aoma\Notify;
use Aoma\Notify\Notify as NotifyInterface;
use Aoma\Notify\NotifyInterface;
use Exception;

class WxWork extends Notify implements NotifyInterface {
Expand Down Expand Up @@ -62,14 +62,17 @@ public function send($type, $title, $msg, $to = [], $extra = [])
$content.= $name.': '.$value.PHP_EOL;
}
}
$to = is_array($to) ? $to : [$to];
if(!empty($to)){
$this->mention = is_array($to) ? $to : [$to];
}
$data = [
'msgtype' => 'markdown',
'markdown' => [
'content' => $content.PHP_EOL,
'mentioned_mobile_list' => $to,
'mentioned_mobile_list' => $this->mention,
]
];
//success response : {"errcode":0,"errmsg":"ok"}
return self::post($this->server.$this->key, [
'Content-Type: application/json'
], json_encode($data, JSON_UNESCAPED_UNICODE));
Expand Down

0 comments on commit f5f7b21

Please sign in to comment.