diff --git a/clientapi/routing/presence.go b/clientapi/routing/presence.go index 80314bfef..63fbb75ef 100644 --- a/clientapi/routing/presence.go +++ b/clientapi/routing/presence.go @@ -45,7 +45,7 @@ func SetPresence( producer *producers.SyncAPIProducer, userID string, ) util.JSONResponse { - if !cfg.Matrix.Presence.EnableInbound { + if !cfg.Matrix.Presence.EnableOutbound { return util.JSONResponse{ Code: http.StatusOK, JSON: struct{}{}, diff --git a/setup/config/config_global.go b/setup/config/config_global.go index 870d1e6bd..c1650f077 100644 --- a/setup/config/config_global.go +++ b/setup/config/config_global.go @@ -41,7 +41,7 @@ type Global struct { // to other servers and the federation API will not be exposed. DisableFederation bool `yaml:"disable_federation"` - // Disable presence. Dendrite will not handle presence events. + // Configures the handling of presence events. Presence PresenceOptions `yaml:"presence"` // List of domains that the server will trust as identity servers to @@ -229,7 +229,10 @@ func (c *DNSCacheOptions) Verify(configErrs *ConfigErrors, isMonolith bool) { checkPositive(configErrs, "cache_lifetime", int64(c.CacheLifetime)) } +// PresenceOptions defines possible configurations for presence events. type PresenceOptions struct { - EnableInbound bool `yaml:"enable_inbound"` + // Whether inbound presence events are allowed + EnableInbound bool `yaml:"enable_inbound"` + // Whether outbound presence events are allowed EnableOutbound bool `yaml:"enable_outbound"` } diff --git a/syncapi/streams/stream_presence.go b/syncapi/streams/stream_presence.go index 032a2ce5a..a24edad59 100644 --- a/syncapi/streams/stream_presence.go +++ b/syncapi/streams/stream_presence.go @@ -65,7 +65,7 @@ func (p *PresenceStreamProvider) IncrementalSync( } // get all joined users - // TODO: SharedUsers might get out of syncf + // TODO: SharedUsers might get out of sync sharedUsers := p.notifier.SharedUsers(req.Device.UserID) sharedUsersMap := map[string]bool{ diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 7af685506..cf667337d 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -80,7 +80,6 @@ func NewRequestPool( producer: producer, } go rp.cleanLastSeen() - go rp.cleanPresence(db, time.Minute*5) return rp } @@ -96,6 +95,9 @@ func (rp *RequestPool) cleanLastSeen() { } func (rp *RequestPool) cleanPresence(db storage.Presence, cleanupTime time.Duration) { + if !rp.cfg.Matrix.Presence.EnableOutbound { + return + } for { rp.presence.Range(func(key interface{}, v interface{}) bool { p := v.(types.PresenceInternal) @@ -111,7 +113,7 @@ func (rp *RequestPool) cleanPresence(db storage.Presence, cleanupTime time.Durat // updatePresence sends presence updates to the SyncAPI and FederationAPI func (rp *RequestPool) updatePresence(db storage.Presence, presence string, userID string) { - if !rp.cfg.Matrix.Presence.EnableInbound { + if !rp.cfg.Matrix.Presence.EnableOutbound { return } if presence == "" {