forked from cwtch.im/cwtch
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
|
||||
}
|
||||
|
||||
// IsServer returns true if the onion address is associated with a server.
|
||||
func (p *PublicProfile) IsServer(onion string) bool {
|
||||
if _, isServer := p.GetAttribute(string(KeyTypeServerOnion)); isServer == true {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
// IsServer returns true if the profile is associated with a server.
|
||||
func (p *PublicProfile) IsServer() (isServer bool) {
|
||||
_, isServer = p.GetAttribute(string(KeyTypeServerOnion))
|
||||
return
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
// 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 {
|
||||
keyBundle := new(model.KeyBundle)
|
||||
err := json.Unmarshal([]byte(serverSpecification), &keyBundle)
|
||||
|
@ -216,7 +219,6 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
|||
if cp.GetContact(onion) == nil {
|
||||
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
|
||||
ab := keyBundle.AttributeBundle()
|
||||
ab["nick"] = onion
|
||||
pp := &model.PublicProfile{Name: onion, Ed25519PublicKey: decodedPub, Authorization: model.AuthUnknown, Onion: onion, Attributes: ab}
|
||||
|
||||
cp.Profile.AddContact(onion, pp)
|
||||
|
|
|
@ -84,9 +84,9 @@ func (ta *TokenboardServer) Listen() {
|
|||
data, _ = json.Marshal(message)
|
||||
ta.connection.Send(data)
|
||||
}
|
||||
newMessages := ta.LegacyMessageStore.FetchMessages()
|
||||
// Set sync and then send any new messages that might have happened while we were syncing
|
||||
ta.connection.SetCapability(groups.CwtchServerSyncedCapability)
|
||||
newMessages := ta.LegacyMessageStore.FetchMessages()
|
||||
if len(newMessages) > len(messages) {
|
||||
for _, message := range newMessages[len(messages):] {
|
||||
data, _ = json.Marshal(groups.Message{MessageType: groups.NewMessageMessage, NewMessage: &groups.NewMessage{EGM: *message}})
|
||||
|
|
Loading…
Reference in New Issue