add storage eventbus calls

This commit is contained in:
erinn 2019-01-28 11:59:00 -08:00
parent 2db7385ce0
commit ad7cddaacf
2 changed files with 30 additions and 2 deletions

View File

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

View File

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