forked from MirrorHub/mautrix-whatsapp
Remove unused read receipt based disappearing timer
This commit is contained in:
parent
3a5ca36d49
commit
b8127f3545
3 changed files with 0 additions and 28 deletions
|
@ -55,10 +55,6 @@ const (
|
|||
getAllScheduledDisappearingMessagesQuery = `
|
||||
SELECT room_id, event_id, expire_in, expire_at FROM disappearing_message WHERE expire_at IS NOT NULL AND expire_at <= $1
|
||||
`
|
||||
startUnscheduledDisappearingMessagesInRoomQuery = `
|
||||
UPDATE disappearing_message SET expire_at=$1+expire_in WHERE room_id=$2 AND expire_at IS NULL
|
||||
RETURNING room_id, event_id, expire_in, expire_at
|
||||
`
|
||||
)
|
||||
|
||||
func (dmq *DisappearingMessageQuery) GetUpcomingScheduled(duration time.Duration) (messages []*DisappearingMessage) {
|
||||
|
@ -72,17 +68,6 @@ func (dmq *DisappearingMessageQuery) GetUpcomingScheduled(duration time.Duration
|
|||
return
|
||||
}
|
||||
|
||||
func (dmq *DisappearingMessageQuery) StartAllUnscheduledInRoom(roomID id.RoomID) (messages []*DisappearingMessage) {
|
||||
rows, err := dmq.db.Query(startUnscheduledDisappearingMessagesInRoomQuery, time.Now().UnixMilli(), roomID)
|
||||
if err != nil || rows == nil {
|
||||
return nil
|
||||
}
|
||||
for rows.Next() {
|
||||
messages = append(messages, dmq.New().Scan(rows))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type DisappearingMessage struct {
|
||||
db *Database
|
||||
log log.Logger
|
||||
|
|
|
@ -40,15 +40,6 @@ func (portal *Portal) MarkDisappearing(txn dbutil.Execable, eventID id.EventID,
|
|||
}
|
||||
}
|
||||
|
||||
func (portal *Portal) ScheduleDisappearing() {
|
||||
nowPlusHour := time.Now().Add(1 * time.Hour)
|
||||
for _, msg := range portal.bridge.DB.DisappearingMessage.StartAllUnscheduledInRoom(portal.MXID) {
|
||||
if msg.ExpireAt.Before(nowPlusHour) {
|
||||
go portal.sleepAndDelete(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (br *WABridge) SleepAndDeleteUpcoming() {
|
||||
for _, msg := range br.DB.DisappearingMessage.GetUpcomingScheduled(1 * time.Hour) {
|
||||
portal := br.GetPortalByMXID(msg.RoomID)
|
||||
|
|
|
@ -280,7 +280,6 @@ var (
|
|||
_ bridge.MembershipHandlingPortal = (*Portal)(nil)
|
||||
_ bridge.MetaHandlingPortal = (*Portal)(nil)
|
||||
_ bridge.TypingPortal = (*Portal)(nil)
|
||||
_ bridge.DisappearingPortal = (*Portal)(nil)
|
||||
)
|
||||
|
||||
func (portal *Portal) handleMessageLoopItem(msg PortalMessage) {
|
||||
|
@ -4255,9 +4254,6 @@ func (portal *Portal) handleMatrixReadReceipt(sender *User, eventID id.EventID,
|
|||
portal.log.Warnfln("Failed to mark %v as read by %s: %v", ids, sender.JID, err)
|
||||
}
|
||||
}
|
||||
if isExplicit {
|
||||
portal.ScheduleDisappearing()
|
||||
}
|
||||
}
|
||||
|
||||
func typingDiff(prev, new []id.UserID) (started, stopped []id.UserID) {
|
||||
|
|
Loading…
Reference in a new issue