From 7044907a4ae5f1d6fdb916d778d02fdc974b9f5b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 3 Sep 2024 22:30:44 +0800 Subject: [PATCH] :bug: Fix whats new include own messages --- pkg/internal/server/api/whats_new_api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/internal/server/api/whats_new_api.go b/pkg/internal/server/api/whats_new_api.go index 84d57cf..3bc0a25 100644 --- a/pkg/internal/server/api/whats_new_api.go +++ b/pkg/internal/server/api/whats_new_api.go @@ -27,16 +27,19 @@ func getWhatsNew(c *fiber.Ctx) error { tx := database.C var lookupRange []uint + var ignoreRange []uint var channelMembers []models.ChannelMember - if err := database.C.Where("account_id = ?", user.ID).Select("channel_id").Find(&channelMembers).Error; err != nil { + if err := database.C.Where("account_id = ?", user.ID).Select("id", "channel_id").Find(&channelMembers).Error; err != nil { return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to get channel identity of you: %v", err)) } else { for _, member := range channelMembers { lookupRange = append(lookupRange, member.ChannelID) + ignoreRange = append(ignoreRange, member.ID) } } tx = tx.Where("channel_id IN ?", lookupRange) + tx = tx.Where("sender_id NOT IN ?", ignoreRange) tx = tx.Where("id > ?", pivot) countTx := tx