Merge branch 's7evink/consent-tracking' of github.com:matrix-org/dendrite into s7evink/consent-tracking

This commit is contained in:
Till Faelligen 2022-04-20 17:35:27 +02:00
commit 1f64fc79c8
7 changed files with 29 additions and 28 deletions

View file

@ -68,4 +68,3 @@ func AddPublicRoutes(
extRoomsProvider, mscCfg, natsClient,
)
}

View file

@ -107,7 +107,7 @@ func sendServerNotice(
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.BadJSON("Invalid request"),
}, fmt.Errorf("invalid server notice request")
}, fmt.Errorf("Invalid JSON")
}
qryServerNoticeRoom := &userapi.QueryServerNoticeRoomResponse{}
@ -177,7 +177,7 @@ func sendServerNotice(
default:
// if we didn't get a createRoomResponse, we probably received an error, so return that.
return roomRes, err
return roomRes, fmt.Errorf("Unable to create room")
}
} else {
@ -188,10 +188,10 @@ func sendServerNotice(
}
// re-invite the user
if res.Membership != gomatrixserverlib.Join {
var sendInviteRes util.JSONResponse
sendInviteRes, err = sendInvite(ctx, userAPI, senderDevice, roomID, serverNoticeRequest.UserID, "Server notice room", cfgClient, rsAPI, asAPI, time.Now())
var inviteRes util.JSONResponse
inviteRes, err = sendInvite(ctx, userAPI, senderDevice, roomID, serverNoticeRequest.UserID, "Server notice room", cfgClient, rsAPI, asAPI, time.Now())
if err != nil {
return sendInviteRes, err
return inviteRes, err
}
}
}
@ -205,7 +205,7 @@ func sendServerNotice(
e, resErr := generateSendEvent(ctx, request, senderDevice, roomID, "m.room.message", nil, cfgClient, rsAPI, time.Now())
if resErr != nil {
logrus.Errorf("failed to send message: %+v", resErr)
return *resErr, err
return *resErr, fmt.Errorf("Unable to send event")
}
timeToGenerateEvent := time.Since(startedGeneratingEvent)
@ -220,7 +220,7 @@ func sendServerNotice(
// pass the new event to the roomserver and receive the correct event ID
// event ID in case of duplicate transaction is discarded
startedSubmittingEvent := time.Now()
if err := api.SendEvents(
if err = api.SendEvents(
ctx, rsAPI,
api.KindNew,
[]*gomatrixserverlib.HeaderedEvent{

View file

@ -397,14 +397,6 @@ func (h *httpUserInternalAPI) PerformSaveThreePIDAssociation(ctx context.Context
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
}
func (h *httpUserInternalAPI) QueryPolicyVersion(ctx context.Context, req *api.QueryPolicyVersionRequest, res *api.QueryPolicyVersionResponse) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryPolicyVersion")
defer span.Finish()
apiURL := h.apiURL + QueryPolicyVersionPath
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
}
func (h *httpUserInternalAPI) QueryOutdatedPolicy(ctx context.Context, req *api.QueryOutdatedPolicyRequest, res *api.QueryOutdatedPolicyResponse) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryOutdatedPolicy")
defer span.Finish()
@ -429,6 +421,14 @@ func (h *httpUserInternalAPI) SelectServerNoticeRoomID(ctx context.Context, req
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
}
func (h *httpUserInternalAPI) QueryPolicyVersion(ctx context.Context, req *api.QueryPolicyVersionRequest, res *api.QueryPolicyVersionResponse) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryPolicyVersion")
defer span.Finish()
apiURL := h.apiURL + QueryPolicyVersionPath
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
}
func (h *httpUserInternalAPI) UpdateServerNoticeRoomID(ctx context.Context, req *api.UpdateServerNoticeRoomRequest, res *api.UpdateServerNoticeRoomResponse) (err error) {
span, ctx := opentracing.StartSpanFromContext(ctx, "UpdateServerNoticeRoomID")
defer span.Finish()

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"time"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/dendrite/clientapi/userutil"
@ -232,7 +233,7 @@ func (s *accountsStatements) BatchSelectPrivacyPolicy(
stmt = sqlutil.TxStmt(txn, stmt)
}
rows, err := stmt.QueryContext(ctx, policyVersion)
defer rows.Close()
defer internal.CloseAndLogIfError(ctx, rows, "BatchSelectPrivacyPolicy: rows.close() failed")
for rows.Next() {
var userID string
if err := rows.Scan(&userID); err != nil {

View file

@ -19,6 +19,7 @@ import (
"database/sql"
"time"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/dendrite/clientapi/userutil"
@ -235,7 +236,7 @@ func (s *accountsStatements) BatchSelectPrivacyPolicy(
if err != nil {
return nil, err
}
defer rows.Close()
defer internal.CloseAndLogIfError(ctx, rows, "BatchSelectPrivacyPolicy: rows.close() failed")
for rows.Next() {
var userID string
if err := rows.Scan(&userID); err != nil {