mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 17:23:09 -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 {
|
||||
return *r
|
||||
}
|
||||
if !cfg.Matrix.PresenceEnabled {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
}
|
||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||
if err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
|
|
@ -1115,7 +1121,12 @@ func Setup(
|
|||
if err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
|
||||
if !cfg.Matrix.PresenceEnabled {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: struct{}{},
|
||||
}
|
||||
}
|
||||
return GetPresence(req, userAPI, vars["userId"], rsAPI, device)
|
||||
}),
|
||||
).Methods(http.MethodGet, http.MethodOptions)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ global:
|
|||
# - private_key: old_matrix_key.pem
|
||||
# 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
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -168,16 +168,17 @@ func Send(
|
|||
servers federationAPI.ServersInRoomProvider,
|
||||
) util.JSONResponse {
|
||||
t := txnReq{
|
||||
rsAPI: rsAPI,
|
||||
eduAPI: eduAPI,
|
||||
userAPI: userAPI,
|
||||
keys: keys,
|
||||
federation: federation,
|
||||
hadEvents: make(map[string]bool),
|
||||
haveEvents: make(map[string]*gomatrixserverlib.HeaderedEvent),
|
||||
servers: servers,
|
||||
keyAPI: keyAPI,
|
||||
roomsMu: mu,
|
||||
rsAPI: rsAPI,
|
||||
eduAPI: eduAPI,
|
||||
userAPI: userAPI,
|
||||
keys: keys,
|
||||
federation: federation,
|
||||
hadEvents: make(map[string]bool),
|
||||
haveEvents: make(map[string]*gomatrixserverlib.HeaderedEvent),
|
||||
servers: servers,
|
||||
keyAPI: keyAPI,
|
||||
roomsMu: mu,
|
||||
presenceEnabled: cfg.Matrix.PresenceEnabled,
|
||||
}
|
||||
|
||||
var txnEvents struct {
|
||||
|
|
@ -244,6 +245,7 @@ type txnReq struct {
|
|||
haveEvents map[string]*gomatrixserverlib.HeaderedEvent
|
||||
haveEventsMutex sync.Mutex
|
||||
work string // metrics
|
||||
presenceEnabled bool
|
||||
}
|
||||
|
||||
func (t *txnReq) hadEvent(eventID string, had bool) {
|
||||
|
|
@ -508,7 +510,9 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
case gomatrixserverlib.MPresence:
|
||||
t.handlePresence(ctx, e)
|
||||
if t.presenceEnabled {
|
||||
t.handlePresence(ctx, e)
|
||||
}
|
||||
case eduserverAPI.MSigningKeyUpdate:
|
||||
var updatePayload eduserverAPI.CrossSigningKeyUpdate
|
||||
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.
|
||||
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
|
||||
// verify third-party identifiers.
|
||||
// Defaults to an empty array.
|
||||
|
|
|
|||
Loading…
Reference in a new issue