Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Add consent tracking#2188

Closed
S7evinK wants to merge 82 commits intomainfrom
s7evink/consent-tracking
Closed

Add consent tracking#2188
S7evinK wants to merge 82 commits intomainfrom
s7evink/consent-tracking

Conversation

@S7evinK
Copy link
Contributor

@S7evinK S7evinK commented Feb 15, 2022

This adds the unspecified consent tracking.
Most parts are documented here

  • When creating a new account, the user now has to accept the specified terms an services (or what ever you call it via the config)
  • If enabled after the account was created, the user is blocked from sending any messages/joining rooms and will receive a message to accept the terms before being able to do anything
  • Asking the user to accept the policy (e.g. via server notices) can be done with Implement server notices #2180. (once merged, needs additional work)

@S7evinK S7evinK force-pushed the s7evink/consent-tracking branch from 6d4153b to 74da1f0 Compare February 17, 2022 16:12
}
err := s.QueryPolicyVersion(req.Context(), &request, &response)
if err != nil {
return util.JSONResponse{Code: http.StatusBadRequest, JSON: &response}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with other code. This should be a 500, use util.ErrorResponse(err). Also, we seem to drop err to the floor?

}

func (c *UserConsentOptions) Verify(configErrors *ConfigErrors, isMonolith bool) {
if c.Enabled {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invert and outdent please:

if !c.Enabled {
    return
}
// rest of code

}

c.TextTemplates = textTemplate.Must(textTemplate.New("blockEventsError").Parse(c.BlockEventsError))
c.TextTemplates = textTemplate.Must(c.TextTemplates.New("serverNoticeTemplate").Parse(c.ServerNoticeContent.Body))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this just replace the stuff we did on :307?

localpart, _, err := gomatrixserverlib.SplitID('@', data.UserID)
if err != nil {
logrus.WithError(err).Error("unable to split username")
return &internalError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be a 4xx given the user can randomly set data.UserID.

ReadOnly bool
}

func consent(writer http.ResponseWriter, req *http.Request, userAPI userapi.UserInternalAPI, cfg *config.ClientAPI) *util.JSONResponse {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a great function signature because it's not clear how precedence works between the return arg and writer. If I write to writer and then also return a util.JSONResponse, what happens?

stmt = sqlutil.TxStmt(txn, stmt)
}
err = stmt.QueryRowContext(ctx, localPart).Scan(&policy)
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle sql.ErrNoRows. We probably don't want to produce an error here.

) (userIDs []string, err error) {
stmt := s.batchSelectPrivacyPolicyStmt
if txn != nil {
stmt = sqlutil.TxStmt(txn, stmt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, no need for the conditional.

row := stmt.QueryRowContext(ctx, localpart)
err = row.Scan(&roomIDNull)
if err != nil {
return "", err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle sql.ErrNoRows. We probably don't want to produce an error here.

if accountType != api.AccountTypeAppService {
_, err = sqlutil.TxStmt(txn, stmt).ExecContext(ctx, localpart, createdTimeMS, hash, nil, accountType)
} else {
_, err = sqlutil.TxStmt(txn, stmt).ExecContext(ctx, localpart, createdTimeMS, hash, appserviceID, accountType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you removed this.

stmt = sqlutil.TxStmt(txn, stmt)
}
err = stmt.QueryRowContext(ctx, localPart).Scan(&policy)
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same deal, handle sql.ErrNoRows.

@kegsay
Copy link
Member

kegsay commented Dec 5, 2022

We recently updated our contributing guidelines. This PR is being closed because it isn't a feature we want to maintain going forwards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants