Add name/bio updating API
This commit is contained in:
parent
8b349fd0ea
commit
f21a8baa1e
27
api/actions/setprofile.php
Normal file
27
api/actions/setprofile.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$profile = $database->get("accounts", ["[>]authkeys" => ["accountid"]], ["accounts.accountid","name", "bio"], ["key" => $VARS["key"]]);
|
||||||
|
|
||||||
|
if (!empty($VARS["name"])) {
|
||||||
|
if (strlen($VARS["name"]) > 200) {
|
||||||
|
sendJsonResp($Strings->get("Name is too long (max 200 characters)."), "ERROR");
|
||||||
|
}
|
||||||
|
$profile["name"] = htmlentities($VARS["name"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($VARS["bio"])) {
|
||||||
|
$profile["bio"] = htmlentities($VARS["bio"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$database->update("accounts", [
|
||||||
|
"name" => $profile["name"],
|
||||||
|
"bio" => $profile["bio"],
|
||||||
|
], ["accountid" => $profile["accountid"]]);
|
||||||
|
|
||||||
|
sendJsonResp();
|
@ -66,6 +66,14 @@ $APIS = [
|
|||||||
"id (optional)" => "/[0-9a-z]+/"
|
"id (optional)" => "/[0-9a-z]+/"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"setprofile" => [
|
||||||
|
"load" => "setprofile.php",
|
||||||
|
"vars" => [
|
||||||
|
"key" => $keyregex,
|
||||||
|
"name (optional)" => "string",
|
||||||
|
"bio (optional)" => "string"
|
||||||
|
]
|
||||||
|
],
|
||||||
"getnearby" => [
|
"getnearby" => [
|
||||||
"load" => "nearby.php",
|
"load" => "nearby.php",
|
||||||
"vars" => [
|
"vars" => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user