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

@ -24,6 +24,7 @@ import (
"os"
"github.com/skip2/go-qrcode"
log "maunium.net/go/maulogger"
"maunium.net/go/mautrix-whatsapp/types"
)
type User struct {
@ -33,12 +34,12 @@ type User struct {
bridge *Bridge
log log.Logger
portalsByMXID map[string]*Portal
portalsByJID map[string]*Portal
puppets map[string]*Portal
portalsByMXID map[types.MatrixRoomID]*Portal
portalsByJID map[types.WhatsAppID]*Portal
puppets map[types.WhatsAppID]*Puppet
}
func (bridge *Bridge) GetUser(userID string) *User {
func (bridge *Bridge) GetUser(userID types.MatrixUserID) *User {
user, ok := bridge.users[userID]
if !ok {
dbUser := bridge.DB.User.Get(userID)