fix private chat room name/avatar update bug

This commit is contained in:
zhaoYangguang 2020-11-04 17:14:11 +08:00
parent 04b043426e
commit 5dcee4ba03
2 changed files with 14 additions and 14 deletions

View File

@ -272,7 +272,8 @@ func (puppet *Puppet) UpdateName(source *User, contact skype.Contact) bool {
func (puppet *Puppet) updatePortalMeta(meta func(portal *Portal)) { func (puppet *Puppet) updatePortalMeta(meta func(portal *Portal)) {
if puppet.bridge.Config.Bridge.PrivateChatPortalMeta { if puppet.bridge.Config.Bridge.PrivateChatPortalMeta {
for _, portal := range puppet.bridge.GetAllPortalsByJID(puppet.JID) { jid := strings.Replace(puppet.JID, whatsappExt.NewUserSuffix, "", 1)
for _, portal := range puppet.bridge.GetAllPortalsByJID(jid) {
meta(portal) meta(portal)
} }
} }
@ -306,7 +307,6 @@ func (puppet *Puppet) updatePortalName() {
} }
func (puppet *Puppet) Sync(source *User, contact skype.Contact) { func (puppet *Puppet) Sync(source *User, contact skype.Contact) {
fmt.Println("sync")
err := puppet.DefaultIntent().EnsureRegistered() err := puppet.DefaultIntent().EnsureRegistered()
if err != nil { if err != nil {
puppet.log.Errorln("Failed to ensure registered:", err) puppet.log.Errorln("Failed to ensure registered:", err)

24
user.go
View File

@ -21,7 +21,6 @@ import (
waProto "github.com/Rhymen/go-whatsapp/binary/proto" waProto "github.com/Rhymen/go-whatsapp/binary/proto"
"maunium.net/go/mautrix/event" "maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"maunium.net/go/mautrix/id" "maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/database" "github.com/kelaresg/matrix-skype/database"
@ -969,17 +968,18 @@ func (user *User) HandleCommand(cmd skypeExt.Command) {
go portal.UpdateAvatar(user, cmd.ProfilePicInfo) go portal.UpdateAvatar(user, cmd.ProfilePicInfo)
} }
case skypeExt.CommandDisconnect: case skypeExt.CommandDisconnect:
var msg string //var msg string
if cmd.Kind == "replaced" { //if cmd.Kind == "replaced" {
msg = "\u26a0 Your WhatsApp connection was closed by the server because you opened another WhatsApp Web client.\n\n" + // msg = "\u26a0 Your Skype connection was closed by the server because you opened another Skype Web client.\n\n" +
"Use the `reconnect` command to disconnect the other client and resume bridging." // "Use the `reconnect` command to disconnect the other client and resume bridging."
} else { //} else {
user.log.Warnln("Unknown kind of disconnect:", string(cmd.Raw)) // user.log.Warnln("Unknown kind of disconnect:", string(cmd.Raw))
msg = fmt.Sprintf("\u26a0 Your WhatsApp connection was closed by the server (reason code: %s).\n\n"+ // msg = fmt.Sprintf("\u26a0 Your Skype connection was closed by the server (reason code: %s).\n\n"+
"Use the `reconnect` command to reconnect.", cmd.Kind) // "Use the `reconnect` command to reconnect.", cmd.Kind)
} //}
user.cleanDisconnection = true //msg = "can not disconnect"
go user.bridge.Bot.SendMessageEvent(user.GetManagementRoom(), event.EventMessage, format.RenderMarkdown(msg, true, false)) //user.cleanDisconnection = true
//go user.bridge.Bot.SendMessageEvent(user.GetManagementRoom(), event.EventMessage, format.RenderMarkdown(msg, true, false))
} }
} }