Refactor structs with some getters/setters - Peers part
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -21,16 +21,21 @@ type Peer struct {
|
||||
MyAvatar string `json:"my_avatar,omitempty"`
|
||||
// Conversation []InternalMessage `json:"conversation,omitempty"`
|
||||
// My own keys for that peer
|
||||
MyIdentity meowlib.KeyPair `json:"my_identity,omitempty"`
|
||||
MyEncryptionKp meowlib.KeyPair `json:"my_encryption_kp,omitempty"`
|
||||
MyLookupKp meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
|
||||
MyPullServers []meowlib.ServerCard `json:"my_pull_servers,omitempty"`
|
||||
MyContact meowlib.ContactCard `json:"my_contact,omitempty"`
|
||||
MyIdentity meowlib.KeyPair `json:"my_identity,omitempty"`
|
||||
MyEncryptionKp meowlib.KeyPair `json:"my_encryption_kp,omitempty"`
|
||||
MyLookupKp meowlib.KeyPair `json:"my_lookup_kp,omitempty"`
|
||||
MyPullServers []*meowlib.ServerCard `json:"my_pull_servers,omitempty"`
|
||||
MyContact meowlib.ContactCard `json:"my_contact,omitempty"` // todo : remove
|
||||
// Peer keys and infos
|
||||
Contact meowlib.ContactCard `json:"contact,omitempty"`
|
||||
InvitationId string `json:"invitation_id,omitempty"`
|
||||
InvitationUrl string `json:"invitation_url,omitempty"`
|
||||
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
|
||||
Contact meowlib.ContactCard `json:"contact,omitempty"` // todo : remove
|
||||
ContactPublicKey string `json:"contact_public_key,omitempty"`
|
||||
ContactLookupKey string `json:"contact_lookup_key,omitempty"`
|
||||
ContactEncryption string `json:"contact_encryption,omitempty"`
|
||||
ContactPullServers []string `json:"contact_pull_servers,omitempty"`
|
||||
InvitationId string `json:"invitation_id,omitempty"`
|
||||
InvitationUrl string `json:"invitation_url,omitempty"`
|
||||
InvitationMessage string `json:"invitation_message,omitempty"`
|
||||
InvitationExpiry time.Time `json:"invitation_expiry,omitempty"`
|
||||
// Internal management attributes
|
||||
Visible bool `json:"visible,omitempty"`
|
||||
VisiblePassword string `json:"visible_password,omitempty"`
|
||||
@ -41,9 +46,39 @@ type Peer struct {
|
||||
DirectMode bool `json:"direct_mode,omitempty"`
|
||||
LastMessage time.Time `json:"last_message,omitempty"`
|
||||
DbIds []string `json:"db_ids,omitempty"`
|
||||
IsDevice bool `json:"is_device,omitempty"`
|
||||
dbPassword string
|
||||
}
|
||||
|
||||
//
|
||||
// getters and setters
|
||||
//
|
||||
|
||||
func (p *Peer) GetMyContact() *meowlib.ContactCard {
|
||||
var c meowlib.ContactCard
|
||||
c.ContactPublicKey = p.MyIdentity.Public
|
||||
c.LookupPublicKey = p.MyLookupKp.Public
|
||||
c.EncryptionPublicKey = p.MyEncryptionKp.Public
|
||||
c.PullServers = p.MyPullServers
|
||||
c.InvitationId = p.InvitationId
|
||||
c.InvitationMessage = p.InvitationMessage
|
||||
c.Name = p.MyName
|
||||
return &c
|
||||
}
|
||||
|
||||
func (p *Peer) GetContact() *meowlib.ContactCard {
|
||||
|
||||
var c meowlib.ContactCard
|
||||
c.ContactPublicKey = p.ContactPublicKey
|
||||
c.LookupPublicKey = p.ContactLookupKey
|
||||
c.EncryptionPublicKey = p.ContactEncryption
|
||||
// c.PullServers = meowlib.LoadServerCardsFromUids(p.ContactPullServers)
|
||||
c.InvitationId = p.InvitationId
|
||||
c.InvitationMessage = p.InvitationMessage
|
||||
c.Name = p.Name
|
||||
return &c
|
||||
}
|
||||
|
||||
//
|
||||
// Messages building
|
||||
//
|
||||
|
Reference in New Issue
Block a user