sum7
/
yaja
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
yaja/model/account.go

42 lines
556 B
Go
Raw Normal View History

package model
import (
"errors"
"sync"
)
type Domain struct {
FQDN string
Accounts map[string]*Account
sync.Mutex
}
func (d *Domain) GetJID() *JID {
return &JID{
Domain: d.FQDN,
}
}
func (d *Domain) UpdateAccount(a *Account) error {
if a.Local == "" {
return errors.New("No localpart exists in account")
}
d.Lock()
d.Accounts[a.Local] = a
d.Unlock()
a.Domain = d
return nil
}
type Account struct {
Local string
Domain *Domain
}
func (a *Account) GetJID() *JID {
return &JID{
Domain: a.Domain.FQDN,
Local: a.Local,
}
}