minor support to manage profile servers

This commit is contained in:
Dan Ballard 2021-11-20 10:10:14 -08:00
parent 79a87b78e0
commit 25d035267a
5 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,9 @@ const ProfileTypeV1Password = "v1-userPassword"
// PeerOnline stores state on if the peer believes it is online
const PeerOnline = "peer-online"
// Description is used on server contacts,
const Description = "description"
const StateProfilePane = "state-profile-pane"
const StateSelectedConversation = "state-selected-conversation"
const StateSelectedProfileTime = "state-selected-profile-time"

View File

@ -7,6 +7,8 @@ import (
"cwtch.im/cwtch/peer"
"cwtch.im/cwtch/protocol/connections"
"fmt"
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/servers"
)
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})
}
}
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}
}

View File

@ -8,5 +8,6 @@ type ServerKey struct {
type Server struct {
Onion string `json:"onion"`
Status string `json:"status"`
Description string `json:"description"`
Keys []ServerKey `json:"keys"`
}

View File

@ -2,6 +2,7 @@ package servers
import (
"cwtch.im/cwtch/event"
"cwtch.im/cwtch/model/attr"
"fmt"
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
"git.openprivacy.ca/cwtch.im/server"
@ -30,6 +31,9 @@ const (
IntentStopped = "stopped"
)
// TODO: move into Cwtch model/attr
const ServerZone = attr.Zone("server")
type ServerInfo struct {
Onion string
ServerBundle string

1
lib.go
View File

@ -323,6 +323,7 @@ func SendAppEvent(eventJson string) {
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)
if err == nil {
servers.InitServers(globalACN, globalAppDir)