Formatting / Linting
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2023-07-25 11:18:55 -07:00
parent 8d7052bb8d
commit f2ad64fe8b
2 changed files with 13 additions and 16 deletions

View File

@ -1,14 +1,13 @@
package servers package servers
import ( import (
"cwtch.im/cwtch/event" "cwtch.im/cwtch/event"
"cwtch.im/cwtch/model" "cwtch.im/cwtch/model"
"cwtch.im/cwtch/model/attr" "cwtch.im/cwtch/model/attr"
"cwtch.im/cwtch/model/constants" "cwtch.im/cwtch/model/constants"
"cwtch.im/cwtch/peer" "cwtch.im/cwtch/peer"
"cwtch.im/cwtch/settings"
"cwtch.im/cwtch/protocol/connections" "cwtch.im/cwtch/protocol/connections"
"cwtch.im/cwtch/settings"
"encoding/json" "encoding/json"
) )
@ -28,7 +27,7 @@ type Functionality struct {
func (f *Functionality) NotifySettingsUpdate(settings settings.GlobalSettings) { func (f *Functionality) NotifySettingsUpdate(settings settings.GlobalSettings) {
} }
func (f *Functionality) EventsToRegister() []event.Type { func (f *Functionality) EventsToRegister() []event.Type {
return []event.Type{event.ProtocolEngineCreated, event.ManifestReceived, event.FileDownloaded} return []event.Type{event.ProtocolEngineCreated, event.ManifestReceived, event.FileDownloaded}
@ -42,11 +41,10 @@ func (f *Functionality) ExperimentsToRegister() []string {
func (f *Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) { func (f *Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
if profile.IsFeatureEnabled(constants.GroupsExperiment) { if profile.IsFeatureEnabled(constants.GroupsExperiment) {
switch ev.EventType { switch ev.EventType {
// keep the UI in sync with the current backend server updates... // keep the UI in sync with the current backend server updates...
// TODO: do we need a secondary heartbeat for less common updates? // TODO: do we need a secondary heartbeat for less common updates?
case event.Heartbeat: case event.Heartbeat:
f.PublishServerUpdate(profile) f.PublishServerUpdate(profile)
break;
} }
} }
} }
@ -56,7 +54,7 @@ func (f *Functionality) OnContactRequestValue(profile peer.CwtchPeer, conversati
} }
func (f *Functionality) OnContactReceiveValue(profile peer.CwtchPeer, conversation model.Conversation, path attr.ScopedZonedPath, value string, exists bool) { func (f *Functionality) OnContactReceiveValue(profile peer.CwtchPeer, conversation model.Conversation, path attr.ScopedZonedPath, value string, exists bool) {
// nopt // nopt
} }
// FunctionalityGate returns filesharing functionality - gates now happen on function calls. // FunctionalityGate returns filesharing functionality - gates now happen on function calls.
@ -77,7 +75,6 @@ type SyncStatus struct {
LastMessageTime string `json:"lastMessageTime"` LastMessageTime string `json:"lastMessageTime"`
} }
// Server encapsulates the information needed to represent a server... // Server encapsulates the information needed to represent a server...
type Server struct { type Server struct {
Onion string `json:"onion"` Onion string `json:"onion"`
@ -90,9 +87,9 @@ type Server struct {
// PublishServerUpdate serializes the current list of group servers and publishes an event with this information // PublishServerUpdate serializes the current list of group servers and publishes an event with this information
func (f *Functionality) PublishServerUpdate(profile peer.CwtchPeer) { func (f *Functionality) PublishServerUpdate(profile peer.CwtchPeer) {
serverListForOnion := f.GetServerInfoList(profile) serverListForOnion := f.GetServerInfoList(profile)
serversListBytes, _ := json.Marshal(serverListForOnion) serversListBytes, _ := json.Marshal(serverListForOnion)
profile.PublishEvent(event.NewEvent(UpdateServerInfo, map[event.Field]string{"ProfileOnion": profile.GetOnion(), ServerList: string(serversListBytes)})) profile.PublishEvent(event.NewEvent(UpdateServerInfo, map[event.Field]string{"ProfileOnion": profile.GetOnion(), ServerList: string(serversListBytes)}))
} }
// GetServerInfoList compiles all the information the UI might need regarding all servers.. // GetServerInfoList compiles all the information the UI might need regarding all servers..

View File

@ -857,9 +857,9 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
// in the table (e.g. deleted messages, expired messages, etc.) // in the table (e.g. deleted messages, expired messages, etc.)
func (cp *cwtchPeer) SearchConversations(pattern string) string { func (cp *cwtchPeer) SearchConversations(pattern string) string {
// TODO: For now, we simply surround the pattern with the sqlite LIKE syntax for matching any prefix, and any suffix // TODO: For now, we simply surround the pattern with the sqlite LIKE syntax for matching any prefix, and any suffix
// At some point we would like to extend this patternt to support e.g. searching a specific conversation, or // At some point we would like to extend this patternt to support e.g. searching a specific conversation, or
// searching for particular types of message. // searching for particular types of message.
pattern = fmt.Sprintf("%%%v%%", pattern) pattern = fmt.Sprintf("%%%v%%", pattern)
// we need this lock here to prevent weirdness happening when reassigning cp.cancelSearchContext // we need this lock here to prevent weirdness happening when reassigning cp.cancelSearchContext