Small Fixes
This commit is contained in:
parent
7c73df1f06
commit
8ed7dd471a
|
@ -78,12 +78,10 @@ func (p *PublicProfile) SetAttribute(name string, value string) {
|
||||||
p.Attributes[name] = value
|
p.Attributes[name] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsServer returns true if the onion address is associated with a server.
|
// IsServer returns true if the profile is associated with a server.
|
||||||
func (p *PublicProfile) IsServer(onion string) bool {
|
func (p *PublicProfile) IsServer() (isServer bool) {
|
||||||
if _, isServer := p.GetAttribute(string(KeyTypeServerOnion)); isServer == true {
|
_, isServer = p.GetAttribute(string(KeyTypeServerOnion))
|
||||||
return true
|
return
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttribute returns the value of a value set with SetCustomAttribute. If no such value has been set exists is set to false.
|
// GetAttribute returns the value of a value set with SetCustomAttribute. If no such value has been set exists is set to false.
|
||||||
|
|
|
@ -205,6 +205,9 @@ func (cp *cwtchPeer) AddContact(nick, onion string, authorization model.Authoriz
|
||||||
cp.eventBus.Publish(event.NewEventList(event.SetPeerAttribute, event.RemotePeer, onion, event.SaveHistoryKey, event.DeleteHistoryDefault))
|
cp.eventBus.Publish(event.NewEventList(event.SetPeerAttribute, event.RemotePeer, onion, event.SaveHistoryKey, event.DeleteHistoryDefault))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddServer takes in a serialized server specification (a bundle of related keys) and adds a contact for the
|
||||||
|
// server assuming there are no errors and the contact doesn't already exist.
|
||||||
|
// TODO in the future this function should also integrate with a trust provider to validate the key bundle.
|
||||||
func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
||||||
keyBundle := new(model.KeyBundle)
|
keyBundle := new(model.KeyBundle)
|
||||||
err := json.Unmarshal([]byte(serverSpecification), &keyBundle)
|
err := json.Unmarshal([]byte(serverSpecification), &keyBundle)
|
||||||
|
@ -216,7 +219,6 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
||||||
if cp.GetContact(onion) == nil {
|
if cp.GetContact(onion) == nil {
|
||||||
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
|
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
|
||||||
ab := keyBundle.AttributeBundle()
|
ab := keyBundle.AttributeBundle()
|
||||||
ab["nick"] = onion
|
|
||||||
pp := &model.PublicProfile{Name: onion, Ed25519PublicKey: decodedPub, Authorization: model.AuthUnknown, Onion: onion, Attributes: ab}
|
pp := &model.PublicProfile{Name: onion, Ed25519PublicKey: decodedPub, Authorization: model.AuthUnknown, Onion: onion, Attributes: ab}
|
||||||
|
|
||||||
cp.Profile.AddContact(onion, pp)
|
cp.Profile.AddContact(onion, pp)
|
||||||
|
|
|
@ -84,9 +84,9 @@ func (ta *TokenboardServer) Listen() {
|
||||||
data, _ = json.Marshal(message)
|
data, _ = json.Marshal(message)
|
||||||
ta.connection.Send(data)
|
ta.connection.Send(data)
|
||||||
}
|
}
|
||||||
newMessages := ta.LegacyMessageStore.FetchMessages()
|
|
||||||
// Set sync and then send any new messages that might have happened while we were syncing
|
// Set sync and then send any new messages that might have happened while we were syncing
|
||||||
ta.connection.SetCapability(groups.CwtchServerSyncedCapability)
|
ta.connection.SetCapability(groups.CwtchServerSyncedCapability)
|
||||||
|
newMessages := ta.LegacyMessageStore.FetchMessages()
|
||||||
if len(newMessages) > len(messages) {
|
if len(newMessages) > len(messages) {
|
||||||
for _, message := range newMessages[len(messages):] {
|
for _, message := range newMessages[len(messages):] {
|
||||||
data, _ = json.Marshal(groups.Message{MessageType: groups.NewMessageMessage, NewMessage: &groups.NewMessage{EGM: *message}})
|
data, _ = json.Marshal(groups.Message{MessageType: groups.NewMessageMessage, NewMessage: &groups.NewMessage{EGM: *message}})
|
||||||
|
|
Loading…
Reference in New Issue