Fix option & typo

This commit is contained in:
Till Faelligen 2022-04-05 16:26:33 +02:00
parent 9356a36813
commit 44215e9f09
4 changed files with 11 additions and 6 deletions

View file

@ -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{}{},

View file

@ -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 {
// Whether inbound presence events are allowed
EnableInbound bool `yaml:"enable_inbound"`
// Whether outbound presence events are allowed
EnableOutbound bool `yaml:"enable_outbound"`
}

View file

@ -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{

View file

@ -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 == "" {