minor support to manage profile servers
This commit is contained in:
parent
79a87b78e0
commit
25d035267a
|
@ -14,6 +14,9 @@ const ProfileTypeV1Password = "v1-userPassword"
|
||||||
// PeerOnline stores state on if the peer believes it is online
|
// PeerOnline stores state on if the peer believes it is online
|
||||||
const PeerOnline = "peer-online"
|
const PeerOnline = "peer-online"
|
||||||
|
|
||||||
|
// Description is used on server contacts,
|
||||||
|
const Description = "description"
|
||||||
|
|
||||||
const StateProfilePane = "state-profile-pane"
|
const StateProfilePane = "state-profile-pane"
|
||||||
const StateSelectedConversation = "state-selected-conversation"
|
const StateSelectedConversation = "state-selected-conversation"
|
||||||
const StateSelectedProfileTime = "state-selected-profile-time"
|
const StateSelectedProfileTime = "state-selected-profile-time"
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"cwtch.im/cwtch/peer"
|
"cwtch.im/cwtch/peer"
|
||||||
"cwtch.im/cwtch/protocol/connections"
|
"cwtch.im/cwtch/protocol/connections"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
|
||||||
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/servers"
|
||||||
)
|
)
|
||||||
|
|
||||||
const groupExperiment = "tapir-groups-experiment"
|
const groupExperiment = "tapir-groups-experiment"
|
||||||
|
@ -54,5 +56,8 @@ func (gf *GroupFunctionality) GetServerInfo(serverOnion string, profile peer.Cwt
|
||||||
serverKeys = append(serverKeys, ServerKey{Type: string(keyType), Key: key})
|
serverKeys = append(serverKeys, ServerKey{Type: string(keyType), Key: key})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Server{Onion: serverOnion, Status: connections.ConnectionStateName[profile.GetPeerState(serverInfo.Handle)], Keys: serverKeys}
|
|
||||||
|
descPath := attr.LocalScope.ConstructScopedZonedPath(servers.ServerZone.ConstructZonedPath(constants.Description))
|
||||||
|
description, _ := serverInfo.GetAttribute(descPath.ToString())
|
||||||
|
return Server{Onion: serverOnion, Status: connections.ConnectionStateName[profile.GetPeerState(serverInfo.Handle)], Keys: serverKeys, Description: description}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,6 @@ type ServerKey struct {
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Onion string `json:"onion"`
|
Onion string `json:"onion"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
Description string `json:"description"`
|
||||||
Keys []ServerKey `json:"keys"`
|
Keys []ServerKey `json:"keys"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package servers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cwtch.im/cwtch/event"
|
"cwtch.im/cwtch/event"
|
||||||
|
"cwtch.im/cwtch/model/attr"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
|
||||||
"git.openprivacy.ca/cwtch.im/server"
|
"git.openprivacy.ca/cwtch.im/server"
|
||||||
|
@ -30,6 +31,9 @@ const (
|
||||||
IntentStopped = "stopped"
|
IntentStopped = "stopped"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: move into Cwtch model/attr
|
||||||
|
const ServerZone = attr.Zone("server")
|
||||||
|
|
||||||
type ServerInfo struct {
|
type ServerInfo struct {
|
||||||
Onion string
|
Onion string
|
||||||
ServerBundle string
|
ServerBundle string
|
||||||
|
|
1
lib.go
1
lib.go
|
@ -323,6 +323,7 @@ func SendAppEvent(eventJson string) {
|
||||||
|
|
||||||
settings := utils.ReadGlobalSettings()
|
settings := utils.ReadGlobalSettings()
|
||||||
|
|
||||||
|
// TODO: Should track state an only launch servers if server experiment re-enabled, not every save of settings
|
||||||
_, err = servers.ExperimentGate(settings.Experiments)
|
_, err = servers.ExperimentGate(settings.Experiments)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
servers.InitServers(globalACN, globalAppDir)
|
servers.InitServers(globalACN, globalAppDir)
|
||||||
|
|
Reference in New Issue