This commit is contained in:
awei
2025-03-03 17:43:50 +08:00
commit 113756eaae
1497 changed files with 127997 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package eventhandler
import (
"bbs-go/internal/models"
"bbs-go/internal/models/constants"
"bbs-go/internal/pkg/event"
"bbs-go/internal/services"
"reflect"
)
func init() {
event.RegHandler(reflect.TypeOf(event.FollowEvent{}), handleFollowEvent)
}
func handleFollowEvent(i interface{}) {
e := i.(event.FollowEvent)
// 将该用户下的帖子添加到信息流
services.TopicService.ScanByUser(e.OtherId, func(topics []models.Topic) {
for _, topic := range topics {
if topic.Status != constants.StatusOk {
continue
}
_ = services.UserFeedService.Create(&models.UserFeed{
UserId: e.UserId,
DataType: constants.EntityTopic,
DataId: topic.Id,
AuthorId: topic.UserId,
CreateTime: topic.CreateTime,
})
}
})
}