|
@@ -50,7 +50,7 @@ func (s *ChatServer) JoinChat(req *JoinRequest, stream ChatService_JoinChatServe
|
|
|
// 发送欢迎消息
|
|
|
welcomeMsg := &Message{
|
|
|
UserId: "系统",
|
|
|
- Text: "欢迎加入聊天室!",
|
|
|
+ Text: "欢迎加入聊天室",
|
|
|
Timestamp: time.Now().Unix(),
|
|
|
}
|
|
|
if err := stream.Send(welcomeMsg); err != nil {
|
|
@@ -87,7 +87,7 @@ func (s *ChatServer) SendMessage(ctx context.Context, msg *Message) (*MessageAck
|
|
|
switch msg.Action {
|
|
|
case "getContacts":
|
|
|
log.Printf("接收%s通讯录信息\n", msg.UserId)
|
|
|
- //go SynchronousContacts(msg.UserId, msg.Text)
|
|
|
+ go SynchronousContacts(msg.UserId, msg.Text)
|
|
|
case "chatHistory":
|
|
|
go AddChatRecord(msg.UserId, msg.Text) // 异步处理
|
|
|
case "sendTalk":
|
|
@@ -248,24 +248,34 @@ func (s *ChatServer) SpecifyAdminMessage(taskId int64, userMap map[string]interf
|
|
|
config.WxRobot.Insert("send_record", map[string]interface{}{
|
|
|
"task_id": taskId,
|
|
|
"base_user_id": gconv.String(userMap["baseUserId"]),
|
|
|
- "send_status": 3,
|
|
|
+ "send_status": 1,
|
|
|
"create_time": time.Now().Format(time.DateTime),
|
|
|
"batch_code": batchCode,
|
|
|
+ "remark": "用户拒绝",
|
|
|
})
|
|
|
return nil
|
|
|
}
|
|
|
s.mu.Lock()
|
|
|
ch, exists := s.clients[userId] // 直接获取目标用户的 channel
|
|
|
s.mu.Unlock()
|
|
|
- config.WxRobot.Insert("send_record", map[string]interface{}{
|
|
|
- "task_id": taskId,
|
|
|
- "base_user_id": gconv.String(userMap["baseUserId"]),
|
|
|
- "send_status": 1,
|
|
|
- "create_time": time.Now().Format(time.DateTime),
|
|
|
- "batch_code": batchCode,
|
|
|
- })
|
|
|
if !exists {
|
|
|
+ config.WxRobot.Insert("send_record", map[string]interface{}{
|
|
|
+ "task_id": taskId,
|
|
|
+ "base_user_id": gconv.String(userMap["baseUserId"]),
|
|
|
+ "send_status": 1,
|
|
|
+ "create_time": time.Now().Format(time.DateTime),
|
|
|
+ "batch_code": batchCode,
|
|
|
+ "remark": fmt.Sprintf("%s客户端关闭", userId),
|
|
|
+ })
|
|
|
return fmt.Errorf("用户 %s 不存在或未连接", userId)
|
|
|
+ } else {
|
|
|
+ config.WxRobot.Insert("send_record", map[string]interface{}{
|
|
|
+ "task_id": taskId,
|
|
|
+ "base_user_id": gconv.String(userMap["baseUserId"]),
|
|
|
+ "send_status": 1,
|
|
|
+ "create_time": time.Now().Format(time.DateTime),
|
|
|
+ "batch_code": batchCode,
|
|
|
+ })
|
|
|
}
|
|
|
text := gconv.String(map[string]interface{}{
|
|
|
"user": userMap,
|