tourze/wechat-work-msg-audit-bundle
最新稳定版本:0.0.1
Composer 安装命令:
composer require tourze/wechat-work-msg-audit-bundle
包简介
企业微信会话内容存档管理 Symfony Bundle
README 文档
README
A Symfony bundle for WeChat Work (企业微信) conversation content archiving functionality.
Features
- Automatic synchronization of archived messages from WeChat Work
- Support for various message types (text, image, voice, video, etc.)
- Media file download and storage
- Message querying and management
- Integration with WeChat Work Finance SDK
- Cron job support for automatic message synchronization
Installation
composer require tourze/wechat-work-msg-audit-bundle
Configuration
This bundle requires the following configuration:
- WeChat Work Corp Configuration: Set up your corporation and agent with the message archive application (Special Agent ID: 1000022)
- Private Key: Configure the private key for message decryption in your agent settings
- Storage: Configure filesystem storage for media files
Usage
Console Commands
Sync Archive Messages
Synchronize archived messages from WeChat Work:
# Sync all messages for all configured corporations php bin/console wechat-work:sync-archive-message # Sync messages for a specific corporation php bin/console wechat-work:sync-archive-message <corpId> # Sync messages for a specific agent php bin/console wechat-work:sync-archive-message <corpId> <agentId>
This command:
- Fetches new messages from WeChat Work archive API
- Downloads media files (images, voice, video) automatically
- Stores messages in the database
- Can be configured to run as a cron job (runs every minute by default)
Test Commands
For testing purposes, the bundle includes test commands:
# Simple test command for integration testing
php bin/console test:simple
This command is used internally for testing CommandTester integration.
API Requests
Get Permit User List
Retrieve the list of users who have enabled message archiving:
use WechatWorkMsgAuditBundle\Request\GetPermitUserListRequest; $request = new GetPermitUserListRequest(); $request->setAgent($agent); $request->setType(1); // 1: Office edition, 2: Service edition, 3: Enterprise edition $response = $httpClient->sendRequest($request);
Entities
ArchiveMessage
The main entity for storing archived messages:
use WechatWorkMsgAuditBundle\Entity\ArchiveMessage; // Query messages $messages = $archiveMessageRepository->findBy([ 'corp' => $corp, 'fromUserId' => 'user123', ]); // Access message data $message = $messages[0]; $msgId = $message->getMsgId(); $action = $message->getAction(); // send, recall, or switch $msgType = $message->getMsgType(); // text, image, voice, video, etc. $content = $message->getContent(); // Message content array $msgTime = $message->getMsgTime(); // Message timestamp
Message Actions
The bundle supports three types of message actions:
send- Regular message sendingrecall- Message recallswitch- Enterprise switching log
Advanced Usage
Custom Message Processing
You can extend the message processing functionality by implementing custom handlers:
use WechatWorkMsgAuditBundle\Entity\ArchiveMessage; // Custom message processor class CustomMessageProcessor { public function processMessage(ArchiveMessage $message): void { // Your custom processing logic $content = $message->getContent(); $msgType = $message->getMsgType(); // Handle different message types switch ($msgType) { case 'text': $this->processTextMessage($content); break; case 'image': $this->processImageMessage($content); break; // ... other types } } }
Message Filtering
Filter messages based on specific criteria:
// Filter by date range $messages = $archiveMessageRepository->createQueryBuilder('m') ->where('m.msgTime >= :startDate') ->andWhere('m.msgTime <= :endDate') ->setParameter('startDate', $startDate) ->setParameter('endDate', $endDate) ->getQuery() ->getResult(); // Filter by message type $textMessages = $archiveMessageRepository->findBy([ 'msgType' => 'text', 'corp' => $corp ]);
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher
- WeChat Work Finance SDK
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.
Reference
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03