MCPcopy Create free account
hub / github.com/daodst/chat / CleanExpireHistoryMsgs

Function CleanExpireHistoryMsgs

new_feature/clean_func.go:10–21  ·  view source on GitHub ↗
(interval int64)

Source from the content-addressed store, hash-verified

8)
9
10func CleanExpireHistoryMsgs(interval int64) error {
11 parseDuration, _ := time.ParseDuration(fmt.Sprintf("-%dh", interval*24))
12 expireTime := time.Now().Add(parseDuration)
13 roomIds := new_db.GetAllRoomIds()
14 for _, roomId := range roomIds {
15 ok := new_db.DeleteExpireEventsByRoomId(roomId, expireTime)
16 if !ok {
17 return errors.New("err when cleaning room:" + roomId)
18 }
19 }
20 return nil
21}

Callers 1

Calls 1

AddMethod · 0.80

Tested by 1