Browse Source

fixbug:同步联系人类型问题

boweniac 1 month ago
parent
commit
36b76690fc

+ 3 - 1
internal/service/MessageHandlers/chatroom_push_notice.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"github.com/zeromicro/go-zero/core/logx"
 	"wechat-api/ent/wx"
+	"wechat-api/hook"
 	"wechat-api/internal/pkg/wechat_ws"
 	"wechat-api/internal/svc"
 	"wechat-api/workphone"
@@ -33,7 +34,7 @@ func (f *ChatroomPushNoticeHandler) Handler(msg *wechat_ws.MsgJsonObject) error
 				wx.WxidEQ(message.WeChatId), // Additional filter by organizationId
 			).
 			Only(context.TODO())
-		//hookClient := hook.NewHook("", "", "")
+		hookClient := hook.NewHook("", "", "")
 		for _, friend := range message.ChatRooms {
 			friendType := 2
 			//if friend.Type == 1 {
@@ -42,6 +43,7 @@ func (f *ChatroomPushNoticeHandler) Handler(msg *wechat_ws.MsgJsonObject) error
 			//} else {
 			//	friendType = 1
 			//}
+			_ = hookClient.RequestChatRoomInfo(friend.UserName, message.WeChatId)
 			_, err = f.svcCtx.DB.Contact.Create().
 				SetWxWxid(message.WeChatId).
 				SetType(friendType).

+ 8 - 8
internal/service/MessageHandlers/friend_push_notice.go

@@ -5,7 +5,6 @@ import (
 	"encoding/json"
 	"github.com/zeromicro/go-zero/core/logx"
 	"wechat-api/ent/wx"
-	"wechat-api/hook"
 	"wechat-api/internal/pkg/wechat_ws"
 	"wechat-api/internal/svc"
 	"wechat-api/workphone"
@@ -34,15 +33,15 @@ func (f *FriendPushNoticeHandler) Handler(msg *wechat_ws.MsgJsonObject) error {
 				wx.WxidEQ(message.WeChatId), // Additional filter by organizationId
 			).
 			Only(context.TODO())
-		hookClient := hook.NewHook("", "", "")
+		//hookClient := hook.NewHook("", "", "")
 		for _, friend := range message.Friends {
 			friendType := 1
-			if friend.Type == 1 {
-				friendType = 2
-				_ = hookClient.RequestChatRoomInfo(friend.FriendId, message.WeChatId)
-			} else {
-				friendType = 1
-			}
+			//if friend.Type == 1 {
+			//	friendType = 2
+			//	_ = hookClient.RequestChatRoomInfo(friend.FriendId, message.WeChatId)
+			//} else {
+			//	friendType = 1
+			//}
 			_, err = f.svcCtx.DB.Contact.Create().
 				SetWxWxid(message.WeChatId).
 				SetType(friendType).
@@ -55,6 +54,7 @@ func (f *FriendPushNoticeHandler) Handler(msg *wechat_ws.MsgJsonObject) error {
 				SetOrganizationID(wx_info.OrganizationID).
 				OnConflict().
 				UpdateNewValues().
+				SetType(friendType).
 				SetOrganizationID(wx_info.OrganizationID).
 				ID(context.TODO())