Skip to content

readonly_auth blocks old replicated documents #230

@retrodaredevil

Description

@retrodaredevil

var currentMillis = +new Date();
var millisInPast = currentMillis - newDoc.dateMillis;
if (millisInPast > 25 * 60 * 1000) {
throw {forbidden: "dateMillis field is too far in the past!"}
}

This blocks replication as described here: https://guide.couchdb.org/draft/validation.html

https://docs.couchdb.org/en/stable/ddocs/ddocs.html#validate-document-update-functions

Document validation is optional, and each design document in the database may have at most one validation function. When a write request is received for a given database, the validation function in each design document in that database is called in an unspecified order. If any of the validation functions throw an error, the write will not succeed.

We should also consider not putting this validation logic in _design/packets because if we need to change it, then indices need to be recalculated or whatever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions