Fix read receipts in private chats and remove unnecessary stuff

This commit is contained in:
Tulir Asokan 2018-08-25 15:28:33 +03:00
parent 160ecb0c95
commit 7f91d91f1b
3 changed files with 1 additions and 29 deletions

View file

@ -263,7 +263,6 @@ func (portal *Portal) MainIntent() *appservice.IntentAPI {
func (portal *Portal) IsDuplicate(id types.WhatsAppMessageID) bool {
msg := portal.bridge.DB.Message.GetByJID(portal.Owner, id)
if msg != nil {
portal.log.Debugln("Ignoring duplicate message", id)
return true
}
return false

27
user.go
View file

@ -17,7 +17,6 @@
package main
import (
"fmt"
"strings"
"sync"
"time"
@ -212,7 +211,6 @@ func (user *User) HandleJSONParseError(err error) {
}
func (user *User) HandleTextMessage(message whatsapp.TextMessage) {
user.log.Debugln("Received text message:", message)
portal := user.GetPortalByJID(message.Info.RemoteJid)
portal.HandleTextMessage(message)
}
@ -237,30 +235,6 @@ func (user *User) HandleDocumentMessage(message whatsapp.DocumentMessage) {
portal.HandleMediaMessage(message.Download, message.Thumbnail, message.Info, message.Type, message.Title)
}
func (user *User) HandleStreamEvent(stream whatsapp_ext.StreamEvent) {
if len(user.ManagementRoom) == 0 {
return
}
switch stream.Type {
case whatsapp_ext.StreamSleep:
user.bridge.AppService.BotIntent().SendNotice(user.ManagementRoom, "WhatsApp client disconnected.")
case whatsapp_ext.StreamUpdate:
if user.Conn.Info != nil && user.Conn.Info.Phone != nil {
user.bridge.AppService.BotIntent().SendNotice(user.ManagementRoom,
fmt.Sprintf("WhatsApp v%s client connected from %s %s (OS v%s).",
user.Conn.Info.Phone.WaVersion, user.Conn.Info.Phone.DeviceManufacturer, user.Conn.Info.Phone.DeviceModel, user.Conn.Info.Phone.OsVersion))
}
}
}
func (user *User) HandleConnInfo(info whatsapp_ext.ConnInfo) {
if len(user.ManagementRoom) > 0 && len(info.ProtocolVersion) > 0 {
user.bridge.AppService.BotIntent().SendNotice(user.ManagementRoom,
fmt.Sprintf("WhatsApp v%s client connected from %s %s (OS v%s).",
info.Phone.WhatsAppVersion, info.Phone.DeviceManufacturer, info.Phone.DeviceModel, info.Phone.OSVersion))
}
}
func (user *User) HandlePresence(info whatsapp_ext.Presence) {
puppet := user.GetPuppetByJID(info.SenderJID)
switch info.Status {
@ -290,7 +264,6 @@ func (user *User) HandleMsgInfo(info whatsapp_ext.MsgInfo) {
}
intent := user.GetPuppetByJID(info.SenderJID).Intent()
user.log.Debugln(info.IDs)
for _, id := range info.IDs {
msg := user.bridge.DB.Message.GetByJID(user.ID, id)
if msg == nil {

View file

@ -78,7 +78,7 @@ func (ext *ExtendedConn) handleMessageMsgInfo(msgType JSONMessageType, message [
event.SenderJID = strings.Replace(event.SenderJID, OldUserSuffix, NewUserSuffix, 1)
event.ToJID = strings.Replace(event.ToJID, OldUserSuffix, NewUserSuffix, 1)
if msgType == MessageMsg {
event.SenderJID = event.MessageFromJID
event.SenderJID = event.ToJID
}
for _, handler := range ext.handlers {
msgInfoHandler, ok := handler.(MsgInfoHandler)