Use type aliases for different ID types and add puppet type

This commit is contained in:
Tulir Asokan
2018-08-17 00:11:28 +03:00
parent 141eba644b
commit edd4f817e4
13 changed files with 325 additions and 189 deletions

View File

@ -20,9 +20,10 @@ import (
"maunium.net/go/mautrix-whatsapp/database"
log "maunium.net/go/maulogger"
"fmt"
"maunium.net/go/mautrix-whatsapp/types"
)
func (user *User) GetPortalByMXID(mxid string) *Portal {
func (user *User) GetPortalByMXID(mxid types.MatrixRoomID) *Portal {
portal, ok := user.portalsByMXID[mxid]
if !ok {
dbPortal := user.bridge.DB.Portal.GetByMXID(mxid)
@ -38,7 +39,7 @@ func (user *User) GetPortalByMXID(mxid string) *Portal {
return portal
}
func (user *User) GetPortalByJID(jid string) *Portal {
func (user *User) GetPortalByJID(jid types.WhatsAppID) *Portal {
portal, ok := user.portalsByJID[jid]
if !ok {
dbPortal := user.bridge.DB.Portal.GetByJID(user.UserID, jid)