mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-27 08:41:57 -06:00
Update logging
This commit is contained in:
parent
6622fda08c
commit
c0845ea1ad
|
@ -117,7 +117,6 @@ func sendServerNoticeForConsent(userAPI userapi.UserInternalAPI, rsAPI api.Rooms
|
||||||
accountsDB userdb.Database,
|
accountsDB userdb.Database,
|
||||||
asAPI appserviceAPI.AppServiceQueryAPI,
|
asAPI appserviceAPI.AppServiceQueryAPI,
|
||||||
) {
|
) {
|
||||||
logrus.Infof("Sending server notice to users who have not yet accepted the policy")
|
|
||||||
res := &userapi.QueryOutdatedPolicyUsersResponse{}
|
res := &userapi.QueryOutdatedPolicyUsersResponse{}
|
||||||
if err := userAPI.GetOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyUsersRequest{
|
if err := userAPI.GetOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyUsersRequest{
|
||||||
PolicyVersion: cfgClient.Matrix.UserConsentOptions.Version,
|
PolicyVersion: cfgClient.Matrix.UserConsentOptions.Version,
|
||||||
|
@ -126,10 +125,17 @@ func sendServerNoticeForConsent(userAPI userapi.UserInternalAPI, rsAPI api.Rooms
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
consentOpts := cfgClient.Matrix.UserConsentOptions
|
var (
|
||||||
data := make(map[string]string)
|
consentOpts = cfgClient.Matrix.UserConsentOptions
|
||||||
var err error
|
data = make(map[string]string)
|
||||||
sentMessages := 0
|
err error
|
||||||
|
sentMessages int
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(res.OutdatedUsers) > 0 {
|
||||||
|
logrus.WithField("count", len(res.OutdatedUsers)).Infof("Sending server notice to users who have not yet accepted the policy")
|
||||||
|
}
|
||||||
|
|
||||||
for _, userID := range res.OutdatedUsers {
|
for _, userID := range res.OutdatedUsers {
|
||||||
if userID == cfgClient.Matrix.ServerNotices.LocalPart {
|
if userID == cfgClient.Matrix.ServerNotices.LocalPart {
|
||||||
continue
|
continue
|
||||||
|
@ -140,7 +146,6 @@ func sendServerNoticeForConsent(userAPI userapi.UserInternalAPI, rsAPI api.Rooms
|
||||||
logrus.WithError(err).WithField("userID", userID).Error("unable to construct consentURI")
|
logrus.WithError(err).WithField("userID", userID).Error("unable to construct consentURI")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logrus.Debugf("sending message to %s", userID)
|
|
||||||
msgBody := &bytes.Buffer{}
|
msgBody := &bytes.Buffer{}
|
||||||
|
|
||||||
if err = consentOpts.TextTemplates.ExecuteTemplate(msgBody, "serverNoticeTemplate", data); err != nil {
|
if err = consentOpts.TextTemplates.ExecuteTemplate(msgBody, "serverNoticeTemplate", data); err != nil {
|
||||||
|
@ -174,7 +179,9 @@ func sendServerNoticeForConsent(userAPI userapi.UserInternalAPI, rsAPI api.Rooms
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logrus.Infof("Send messages to %d users", sentMessages)
|
if sentMessages > 0 {
|
||||||
|
logrus.Infof("Sent messages to %d users", sentMessages)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildConsentURI(cfgClient *config.ClientAPI, userID string) (string, error) {
|
func buildConsentURI(cfgClient *config.ClientAPI, userID string) (string, error) {
|
||||||
|
|
Loading…
Reference in a new issue