From ad7cddaacffaa9a39d5259e2a91546aeb4859bc2 Mon Sep 17 00:00:00 2001 From: erinn Date: Mon, 28 Jan 2019 11:59:00 -0800 Subject: [PATCH] add storage eventbus calls --- app/app.go | 6 +++++- event/common.go | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 1d8bd07..45a6dd7 100644 --- a/app/app.go +++ b/app/app.go @@ -67,7 +67,11 @@ func (app *application) CreatePeer(name string, password string) (peer.CwtchPeer profileStore, err := storage.NewProfileStore(app.eventBus, path.Join(app.directory, "profiles", randomFileName), password) profileStore.Init(name) p := peer.NewCwtchPeer(name) - app.eventBus.Publish(event.NewEvent(event.SetProfileName, map[event.Field]string{event.ProfileName: name})) + + app.eventBus.Publish(event.NewEvent(event.SetProfileName, map[event.Field]string{ + event.ProfileName: name, + })) + if err != nil { return nil, err } diff --git a/event/common.go b/event/common.go index b314e3c..e6221eb 100644 --- a/event/common.go +++ b/event/common.go @@ -25,9 +25,32 @@ const ( SendMessageToPeer = Type("SendMessageToPeer") NewMessageFromPeer = Type("NewMessageFromPeer") + // REQUESTS TO STORAGE ENGINE + + // change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!) + // attributes: + // ProfileName [eg "erinn"] SetProfileName = Type("SetProfileName") - RequestProfileSave = Type("RequestProfileSave") + // request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs) + // attributes: + // Key [eg "fontcolor"] + // Data [eg "red"] + SetAttribute = Type("SetAttribute") + + // request to store a per-contact attribute (e.g. display names for a peer) + // attributes: + // RemotePeer [eg ""] + // Key [eg "nick"] + // Data [eg "erinn"] + SetPeerAttribute = Type("SetPeerAttribute") + + // request to store a per-cwtch-group attribute (e.g. display name for a group) + // attributes: + // GroupID [eg ""] + // Key [eg "nick"] + // Data [eg "open privacy board"] + SetGroupAttribute = Type("SetGroupAttribute") ) // Field defines common event attributes @@ -49,6 +72,7 @@ const ( ProfileName = Field("ProfileName") + Key = Field("Key") Data = Field("Data") Error = Field("Error")