Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复应用管理员变更通知判断 #2617

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/src/6.x/open-work/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- 授权成功 `create_auth`
- 授权变更 `change_auth`
- 授权取消 `cancel_auth`
- 通讯录变更(Event) `change_contact`
- 通讯录变更(InfoType) `change_contact`
- ChangeType
- 成员变更
- 新增成员 `create_user`
Expand All @@ -23,6 +23,8 @@
- 标签变更
- 成员标签变更 `update_tag`
- 共享应用事件回调 `share_agent_change`
- 重置永久授权码通知 `reset_permanent_code`
- 应用管理员变更通知 `change_app_admin`

## 内置消息处理器

Expand Down Expand Up @@ -125,6 +127,22 @@ $server->handleShareAgentChanged(function($message, \Closure $next) {
return $next($message);
});
```
### 重置永久授权码通知

```php
$server->handleResetPermanentCode(function($message, \Closure $next) {
// ...
return $next($message);
});
```
### 应用管理员变更通知

```php
$server->handleChangeAppAdmin(function($message, \Closure $next) {
// ...
return $next($message);
});
```

### suite_ticket 推送事件

Expand Down
2 changes: 2 additions & 0 deletions src/OpenWork/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @property string $ChangeType
* @property string $SuiteTicket
* @property string $SuiteId
* @property string $MsgType
* @property string $Event
*/
class Message extends \EasyWeChat\Kernel\Message
{
Expand Down
5 changes: 4 additions & 1 deletion src/OpenWork/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ public function handleResetPermanentCode(callable $handler): static
public function handleChangeAppAdmin(callable $handler): static
{
$this->with(function (Message $message, Closure $next) use ($handler): mixed {
return $message->InfoType === 'change_app_admin' ? $handler($message, $next) : $next($message);
return $message->MsgType === 'event' && $message->Event === 'change_app_admin' ? $handler(
$message,
$next
) : $next($message);
});

return $this;
Expand Down