Fix portal DB scanning and add initial message bridging

This commit is contained in:
Tulir Asokan
2018-08-19 18:21:38 +03:00
parent a9124b89bd
commit c1f8d264f4
5 changed files with 106 additions and 46 deletions

View File

@ -24,6 +24,7 @@ import (
"maunium.net/go/mautrix-whatsapp/types"
"strings"
"maunium.net/go/mautrix-appservice"
"github.com/Rhymen/go-whatsapp"
)
const puppetJIDStrippedSuffix = "@s.whatsapp.net"
@ -132,3 +133,14 @@ type Puppet struct {
func (puppet *Puppet) Intent() *appservice.IntentAPI {
return puppet.bridge.AppService.Intent(puppet.MXID)
}
func (puppet *Puppet) Sync(contact whatsapp.Contact) {
puppet.Intent().EnsureRegistered()
newName := puppet.bridge.Config.Bridge.FormatDisplayname(contact)
if puppet.Displayname != newName {
puppet.Displayname = newName
puppet.Update()
puppet.Intent().SetDisplayName(puppet.Displayname)
}
}