forked from cwtch.im/cwtch
createProfile return onion if possible; add attribute for private name
This commit is contained in:
parent
3e09a25b2d
commit
d5145c631d
16
app/app.go
16
app/app.go
|
@ -53,7 +53,7 @@ func (app *application) IsFeatureEnabled(experiment string) bool {
|
|||
// Application is a full cwtch peer application. It allows management, usage and storage of multiple peers
|
||||
type Application interface {
|
||||
LoadProfiles(password string)
|
||||
CreateProfile(name string, password string, autostart bool)
|
||||
CreateProfile(name string, password string, autostart bool) string
|
||||
InstallEngineHooks(engineHooks connections.EngineHooks)
|
||||
ImportProfile(exportedCwtchFile string, password string) (peer.CwtchPeer, error)
|
||||
EnhancedImportProfile(exportedCwtchFile string, password string) string
|
||||
|
@ -197,7 +197,7 @@ func (app *application) AddPlugin(peerid string, id plugins.PluginID, bus event.
|
|||
}
|
||||
}
|
||||
|
||||
func (app *application) CreateProfile(name string, password string, autostart bool) {
|
||||
func (app *application) CreateProfile(name string, password string, autostart bool) string {
|
||||
autostartVal := constants.True
|
||||
if !autostart {
|
||||
autostartVal = constants.False
|
||||
|
@ -207,10 +207,15 @@ func (app *application) CreateProfile(name string, password string, autostart bo
|
|||
tagVal = constants.ProfileTypeV1DefaultPassword
|
||||
}
|
||||
|
||||
app.CreatePeer(name, password, map[attr.ZonedPath]string{
|
||||
profile_id, err := app.CreatePeer(name, password, map[attr.ZonedPath]string{
|
||||
attr.ProfileZone.ConstructZonedPath(constants.Tag): tagVal,
|
||||
attr.ProfileZone.ConstructZonedPath(constants.PeerAutostart): autostartVal,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
return profile_id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (app *application) setupPeer(profile peer.CwtchPeer) {
|
||||
|
@ -232,7 +237,7 @@ func (app *application) setupPeer(profile peer.CwtchPeer) {
|
|||
|
||||
}
|
||||
|
||||
func (app *application) CreatePeer(name string, password string, attributes map[attr.ZonedPath]string) {
|
||||
func (app *application) CreatePeer(name string, password string, attributes map[attr.ZonedPath]string) (string, error) {
|
||||
app.appmutex.Lock()
|
||||
defer app.appmutex.Unlock()
|
||||
|
||||
|
@ -242,7 +247,7 @@ func (app *application) CreatePeer(name string, password string, attributes map[
|
|||
if err != nil {
|
||||
log.Errorf("Error Creating Peer: %v", err)
|
||||
app.appBus.Publish(event.NewEventList(event.PeerError, event.Error, err.Error()))
|
||||
return
|
||||
return "", err
|
||||
}
|
||||
|
||||
app.setupPeer(profile)
|
||||
|
@ -253,6 +258,7 @@ func (app *application) CreatePeer(name string, password string, attributes map[
|
|||
}
|
||||
|
||||
app.appBus.Publish(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.GetOnion(), event.Created: event.True}))
|
||||
return profile.GetOnion(), nil
|
||||
}
|
||||
|
||||
func (app *application) DeleteProfile(onion string, password string) {
|
||||
|
|
|
@ -58,6 +58,7 @@ const SyncMostRecentMessageTime = "SyncMostRecentMessageTime"
|
|||
const AttrLastConnectionTime = "last-connection-time"
|
||||
const PeerAutostart = "autostart"
|
||||
const PeerAppearOffline = "appear-offline"
|
||||
const PrivateName = "private-name"
|
||||
const Archived = "archived"
|
||||
|
||||
const ProfileStatus = "profile-status"
|
||||
|
|
Loading…
Reference in New Issue