rename db_sanity_check >> db_validate
parent
054c197534
commit
5358639307
|
@ -159,7 +159,7 @@ passed to the server to check it for validity before the
|
|||
user is allowed to continue. Will recurse until the input
|
||||
is valid, then it is returned."
|
||||
(let* ((value (read-from-minibuffer prompt))
|
||||
(response (bbj-request! 'db_sanity_check
|
||||
(response (bbj-request! 'db_validate
|
||||
'value value 'key key)))
|
||||
(if (alist-get 'bool response)
|
||||
value
|
||||
|
|
|
@ -161,7 +161,7 @@ class BBJ(object):
|
|||
|
||||
def validate(self, key, value, exception=AssertionError):
|
||||
"""
|
||||
Uses the server's db_sanity_check method to verify the validty
|
||||
Uses the server's db_validate method to verify the validty
|
||||
of `value` by `key`. If it is invalid, kwarg exception (default
|
||||
AssertionError) is raised with the exception containing the
|
||||
attribute .description as the server's reason. Exception can
|
||||
|
@ -179,7 +179,7 @@ class BBJ(object):
|
|||
is_okay = bbj.validate("title", "teacups and roses <3", exception=None)
|
||||
"""
|
||||
response = self(
|
||||
"db_sanity_check",
|
||||
"db_validate",
|
||||
no_auth=True,
|
||||
key=key,
|
||||
value=value
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
The server has an endpoint called `db_sanity_check`. What this does is take
|
||||
The server has an endpoint called `db_validate`. What this does is take
|
||||
a `key` and a `value` and compares `value` to a set of rules specified by
|
||||
`key`. This is the same function used internally by the database to scan
|
||||
values before committing them to the database. By default it returns a
|
||||
descriptive object under `data`, but you can specify the key/value pair
|
||||
`"error": True` to get a standard error response back. A standard call
|
||||
to `db_sanity_check` will look like this.
|
||||
to `db_validate` will look like this.
|
||||
|
||||
```
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ passed to the server to check it for validity before the
|
|||
user is allowed to continue. Will recurse until the input
|
||||
is valid, then it is returned."
|
||||
(let* ((value (read-from-minibuffer prompt))
|
||||
(response (bbj-request! 'db_sanity_check
|
||||
(response (bbj-request! 'db_validate
|
||||
'value value 'key key)))
|
||||
(if (alist-get 'bool response)
|
||||
value
|
||||
|
|
18
server.py
18
server.py
|
@ -298,7 +298,23 @@ class API(object):
|
|||
|
||||
|
||||
@api_method
|
||||
def db_sanity_check(self, args, database, user, **kwargs):
|
||||
def set_thread_pin(self, args, database, user, **kwargs):
|
||||
"""
|
||||
Requires the arguments `thread_id` and `pinned`. Pinned
|
||||
must be a boolean of what the pinned status should be.
|
||||
This method requires that the caller is logged in and
|
||||
has admin status on their account.
|
||||
|
||||
Returns the same boolean you supply as `pinned`
|
||||
"""
|
||||
validate(args, ["thread_id", "pinned"])
|
||||
if not user["is_admin"]:
|
||||
raise BBJUserError("Only admins can set thread pins")
|
||||
return db.set_thread_pin(database, args["thread_id"], args["pinned"])
|
||||
|
||||
|
||||
@api_method
|
||||
def db_validate(self, args, database, user, **kwargs):
|
||||
"""
|
||||
Requires the arguments `key` and `value`. Returns an object
|
||||
with information about the database sanity criteria for
|
||||
|
|
Loading…
Reference in New Issue