Tapir Server Refactor #317

Merged
dan merged 12 commits from tapir_server into master 2020-09-28 21:56:20 +00:00
3 changed files with 8 additions and 8 deletions
Showing only changes of commit 8ed7dd471a - Show all commits

View File

@ -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.

View File

@ -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))
}
sarah marked this conversation as resolved
Review

Comment (quality.sh misses public methods on structs filling in Interfaces some times wierdly...)

Comment (quality.sh misses public methods on structs filling in Interfaces some times wierdly...)
// 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)

View File

@ -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}})