🐛 Fix whats new include own messages

This commit is contained in:
LittleSheep 2024-09-03 22:30:44 +08:00
parent 8ae33344eb
commit 7044907a4a

View File

@ -27,16 +27,19 @@ func getWhatsNew(c *fiber.Ctx) error {
tx := database.C tx := database.C
var lookupRange []uint var lookupRange []uint
var ignoreRange []uint
var channelMembers []models.ChannelMember 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)) return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to get channel identity of you: %v", err))
} else { } else {
for _, member := range channelMembers { for _, member := range channelMembers {
lookupRange = append(lookupRange, member.ChannelID) lookupRange = append(lookupRange, member.ChannelID)
ignoreRange = append(ignoreRange, member.ID)
} }
} }
tx = tx.Where("channel_id IN ?", lookupRange) tx = tx.Where("channel_id IN ?", lookupRange)
tx = tx.Where("sender_id NOT IN ?", ignoreRange)
tx = tx.Where("id > ?", pivot) tx = tx.Where("id > ?", pivot)
countTx := tx countTx := tx