mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -06:00
Add option to disable presence
This commit is contained in:
parent
0973a4e346
commit
a073a21d71
|
|
@ -1102,6 +1102,12 @@ func Setup(
|
||||||
if r := rateLimits.rateLimit(req); r != nil {
|
if r := rateLimits.rateLimit(req); r != nil {
|
||||||
return *r
|
return *r
|
||||||
}
|
}
|
||||||
|
if !cfg.Matrix.PresenceEnabled {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
JSON: struct{}{},
|
||||||
|
}
|
||||||
|
}
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
|
|
@ -1115,7 +1121,12 @@ func Setup(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
|
if !cfg.Matrix.PresenceEnabled {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
JSON: struct{}{},
|
||||||
|
}
|
||||||
|
}
|
||||||
return GetPresence(req, userAPI, vars["userId"], rsAPI, device)
|
return GetPresence(req, userAPI, vars["userId"], rsAPI, device)
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ global:
|
||||||
# - private_key: old_matrix_key.pem
|
# - private_key: old_matrix_key.pem
|
||||||
# expired_at: 1601024554498
|
# expired_at: 1601024554498
|
||||||
|
|
||||||
|
# Enable/Disable presence. Enabling presence might cause a high load on your server.
|
||||||
|
presence_enabled: false
|
||||||
|
|
||||||
# How long a remote server can cache our server signing key before requesting it
|
# How long a remote server can cache our server signing key before requesting it
|
||||||
# again. Increasing this number will reduce the number of requests made by other
|
# again. Increasing this number will reduce the number of requests made by other
|
||||||
# servers for our key but increases the period that a compromised key will be
|
# servers for our key but increases the period that a compromised key will be
|
||||||
|
|
|
||||||
|
|
@ -168,16 +168,17 @@ func Send(
|
||||||
servers federationAPI.ServersInRoomProvider,
|
servers federationAPI.ServersInRoomProvider,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
t := txnReq{
|
t := txnReq{
|
||||||
rsAPI: rsAPI,
|
rsAPI: rsAPI,
|
||||||
eduAPI: eduAPI,
|
eduAPI: eduAPI,
|
||||||
userAPI: userAPI,
|
userAPI: userAPI,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
federation: federation,
|
federation: federation,
|
||||||
hadEvents: make(map[string]bool),
|
hadEvents: make(map[string]bool),
|
||||||
haveEvents: make(map[string]*gomatrixserverlib.HeaderedEvent),
|
haveEvents: make(map[string]*gomatrixserverlib.HeaderedEvent),
|
||||||
servers: servers,
|
servers: servers,
|
||||||
keyAPI: keyAPI,
|
keyAPI: keyAPI,
|
||||||
roomsMu: mu,
|
roomsMu: mu,
|
||||||
|
presenceEnabled: cfg.Matrix.PresenceEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
var txnEvents struct {
|
var txnEvents struct {
|
||||||
|
|
@ -244,6 +245,7 @@ type txnReq struct {
|
||||||
haveEvents map[string]*gomatrixserverlib.HeaderedEvent
|
haveEvents map[string]*gomatrixserverlib.HeaderedEvent
|
||||||
haveEventsMutex sync.Mutex
|
haveEventsMutex sync.Mutex
|
||||||
work string // metrics
|
work string // metrics
|
||||||
|
presenceEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *txnReq) hadEvent(eventID string, had bool) {
|
func (t *txnReq) hadEvent(eventID string, had bool) {
|
||||||
|
|
@ -508,7 +510,9 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case gomatrixserverlib.MPresence:
|
case gomatrixserverlib.MPresence:
|
||||||
t.handlePresence(ctx, e)
|
if t.presenceEnabled {
|
||||||
|
t.handlePresence(ctx, e)
|
||||||
|
}
|
||||||
case eduserverAPI.MSigningKeyUpdate:
|
case eduserverAPI.MSigningKeyUpdate:
|
||||||
var updatePayload eduserverAPI.CrossSigningKeyUpdate
|
var updatePayload eduserverAPI.CrossSigningKeyUpdate
|
||||||
if err := json.Unmarshal(e.Content, &updatePayload); err != nil {
|
if err := json.Unmarshal(e.Content, &updatePayload); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,9 @@ type Global struct {
|
||||||
// to other servers and the federation API will not be exposed.
|
// to other servers and the federation API will not be exposed.
|
||||||
DisableFederation bool `yaml:"disable_federation"`
|
DisableFederation bool `yaml:"disable_federation"`
|
||||||
|
|
||||||
|
// Enable/Disable presence. Defaults to false
|
||||||
|
PresenceEnabled bool `yaml:"presence_enabled"`
|
||||||
|
|
||||||
// List of domains that the server will trust as identity servers to
|
// List of domains that the server will trust as identity servers to
|
||||||
// verify third-party identifiers.
|
// verify third-party identifiers.
|
||||||
// Defaults to an empty array.
|
// Defaults to an empty array.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue