forked from MirrorHub/mautrix-whatsapp
Try to fix false positive send error on whatsapp mobile
This commit is contained in:
parent
c083afa1ef
commit
80b534323f
4 changed files with 13 additions and 9 deletions
2
go.mod
2
go.mod
|
@ -15,4 +15,4 @@ require (
|
|||
maunium.net/go/mautrix v0.9.12
|
||||
)
|
||||
|
||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.5.3
|
||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.5.4
|
||||
|
|
2
go.sum
2
go.sum
|
@ -470,6 +470,8 @@ github.com/tulir/go-whatsapp v0.5.2 h1:CJcFSAoD/vXybamd9Hfa67Otg11G4EfoIgciQakun
|
|||
github.com/tulir/go-whatsapp v0.5.2/go.mod h1:7J3IIL3bEQiBJGtiZst1N4PgXHlWIartdVQLe6lcx9A=
|
||||
github.com/tulir/go-whatsapp v0.5.3 h1:e3bPLCmbBF146l8tnswqxnVLtGCWOEruJSR4luySh6I=
|
||||
github.com/tulir/go-whatsapp v0.5.3/go.mod h1:7J3IIL3bEQiBJGtiZst1N4PgXHlWIartdVQLe6lcx9A=
|
||||
github.com/tulir/go-whatsapp v0.5.4 h1:S99KYBzuoZ+3mfUDknxiKQEvotKQnzxrPhgoL+o8b/k=
|
||||
github.com/tulir/go-whatsapp v0.5.4/go.mod h1:7J3IIL3bEQiBJGtiZst1N4PgXHlWIartdVQLe6lcx9A=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
|
|
3
main.go
3
main.go
|
@ -17,6 +17,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -196,7 +197,7 @@ func (bridge *Bridge) ensureConnection() {
|
|||
for {
|
||||
resp, err := bridge.Bot.Whoami()
|
||||
if err != nil {
|
||||
if httpErr, ok := err.(mautrix.HTTPError); ok && httpErr.RespError != nil && httpErr.RespError.ErrCode == "M_UNKNOWN_ACCESS_TOKEN" {
|
||||
if errors.Is(err, mautrix.MUnknownToken) {
|
||||
bridge.Log.Fatalln("Access token invalid. Is the registration installed in your homeserver correctly?")
|
||||
os.Exit(16)
|
||||
}
|
||||
|
|
15
portal.go
15
portal.go
|
@ -205,8 +205,8 @@ func (portal *Portal) syncDoublePuppetDetailsAfterCreate(source *User) {
|
|||
return
|
||||
}
|
||||
source.syncChatDoublePuppetDetails(doublePuppet, Chat{
|
||||
Chat: chat,
|
||||
Portal: portal,
|
||||
Chat: chat,
|
||||
Portal: portal,
|
||||
}, true)
|
||||
}
|
||||
|
||||
|
@ -2003,7 +2003,7 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) (*waP
|
|||
}
|
||||
|
||||
ts := uint64(evt.Timestamp / 1000)
|
||||
status := waProto.WebMessageInfo_ERROR
|
||||
status := waProto.WebMessageInfo_PENDING
|
||||
fromMe := true
|
||||
info := &waProto.WebMessageInfo{
|
||||
Key: &waProto.MessageKey{
|
||||
|
@ -2011,9 +2011,10 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) (*waP
|
|||
Id: makeMessageID(),
|
||||
RemoteJid: &portal.Key.JID,
|
||||
},
|
||||
MessageTimestamp: &ts,
|
||||
Message: &waProto.Message{},
|
||||
Status: &status,
|
||||
MessageTimestamp: &ts,
|
||||
MessageC2STimestamp: &ts,
|
||||
Message: &waProto.Message{},
|
||||
Status: &status,
|
||||
}
|
||||
ctxInfo := &waProto.ContextInfo{}
|
||||
replyToID := content.GetReplyTo()
|
||||
|
@ -2187,11 +2188,11 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) {
|
|||
return
|
||||
}
|
||||
dbMsg := portal.markHandled(sender, info, evt.ID, false)
|
||||
portal.log.Debugln("Sending event", evt.ID, "to WhatsApp", info.Key.GetId())
|
||||
portal.sendRaw(sender, evt, info, dbMsg)
|
||||
}
|
||||
|
||||
func (portal *Portal) sendRaw(sender *User, evt *event.Event, info *waProto.WebMessageInfo, dbMsg *database.Message) {
|
||||
portal.log.Debugln("Sending event", evt.ID, "to WhatsApp", info.Key.GetId())
|
||||
errChan := make(chan error, 1)
|
||||
go sender.Conn.SendRaw(info, errChan)
|
||||
|
||||
|
|
Loading…
Reference in a new issue