boweniac 2 月之前
父节点
当前提交
41253fcef9

+ 12 - 4
internal/logic/whatsapp/get_allow_block_list_logic.go

@@ -49,7 +49,9 @@ func (l *GetAllowBlockListLogic) GetAllowBlockList(req *types.IDReq) (resp *type
 		allowListData = "ALL"
 	} else if len(whatsappInfo.AllowList) > 0 {
 		for _, av := range whatsappInfo.AllowList {
-			allowListData += av + "\n"
+			if av != "" {
+				allowListData += av + "\n"
+			}
 		}
 	}
 	resp.Data.AllowList = &allowListData
@@ -59,7 +61,9 @@ func (l *GetAllowBlockListLogic) GetAllowBlockList(req *types.IDReq) (resp *type
 		groupAllowListData = "ALL"
 	} else if len(whatsappInfo.GroupAllowList) > 0 {
 		for _, gav := range whatsappInfo.GroupAllowList {
-			groupAllowListData += gav + "\n"
+			if gav != "" {
+				groupAllowListData += gav + "\n"
+			}
 		}
 	}
 	resp.Data.GroupAllowList = &groupAllowListData
@@ -70,7 +74,9 @@ func (l *GetAllowBlockListLogic) GetAllowBlockList(req *types.IDReq) (resp *type
 			blockListData = "ALL"
 		} else {
 			for _, bv := range whatsappInfo.BlockList {
-				blockListData += bv + "\n"
+				if bv != "" {
+					blockListData += bv + "\n"
+				}
 			}
 		}
 	}
@@ -82,7 +88,9 @@ func (l *GetAllowBlockListLogic) GetAllowBlockList(req *types.IDReq) (resp *type
 			groupBlockListData = "ALL"
 		} else {
 			for _, gbv := range whatsappInfo.GroupBlockList {
-				blockListData += gbv + "\n"
+				if gbv != "" {
+					groupBlockListData += gbv + "\n"
+				}
 			}
 		}
 	}

+ 12 - 4
internal/logic/whatsapp/update_allow_and_block_list_logic.go

@@ -38,17 +38,25 @@ func (l *UpdateAllowAndBlockListLogic) UpdateAllowAndBlockList(req *types.Update
 	var groupAllowListArray []string
 	var blockListArray []string
 	var groupBlockListArray []string
-	if req.AllowList != nil {
+	if req.AllowList != nil && *req.AllowList != "" {
 		allowListArray = strings.Split(*req.AllowList, "\n")
+	} else {
+		allowListArray = []string{"ALL"}
 	}
-	if req.GroupAllowList != nil {
+	if req.GroupAllowList != nil && *req.GroupAllowList != "" {
 		groupAllowListArray = strings.Split(*req.GroupAllowList, "\n")
+	} else {
+		groupAllowListArray = []string{"ALL"}
 	}
-	if req.BlockList != nil {
+	if req.BlockList != nil && *req.GroupAllowList != "" {
 		blockListArray = strings.Split(*req.BlockList, "\n")
+	} else {
+		blockListArray = []string{""}
 	}
-	if req.GroupBlockList != nil {
+	if req.GroupBlockList != nil && *req.GroupAllowList != "" {
 		groupBlockListArray = strings.Split(*req.GroupBlockList, "\n")
+	} else {
+		groupBlockListArray = []string{""}
 	}
 	err = l.svcCtx.DB.Whatsapp.UpdateOneID(req.Id).
 		Where(predicates...).