Commit ac2678d5 authored by thiaramus's avatar thiaramus
Browse files

Nodelist API endpoint to search SysOp name by AKA

parent 620a3f53
......@@ -68,4 +68,12 @@ Expected GET data:
* search: Sysop name to search for (String)
```
GET: /nodelist/akasearch
```
Expected GET data:
* search: AKA to look up SysOp name by (String)
(*) - Not yet implemented. Syntax might be slightly changed.
\ No newline at end of file
......@@ -26,7 +26,7 @@
private function nameSearch($name) {
if (!$name) {
$this->syntaxErrorMessage('Search query is undefined');
$this->syntaxErrorMessage('Sysop name is undefined');
}
$nodelist = new nodelist();
......@@ -40,6 +40,22 @@
return $ret;
}
private function akaSearch($aka) {
if (!$aka) {
$this->syntaxErrorMessage('Aka is undefined');
}
$nodelist = new nodelist();
$result = array();
foreach ($this->config['nodelists'] as $n) {
$nodelist->readFile($nodelist->getLatest($n));
$result []= $nodelist->findAka($aka);
}
return $result;
}
public function run() {
if (!array_key_exists(1, $this->apiCallPath)) {
$this->syntaxErrorMessage('Nodelist function is undefined');
......@@ -48,6 +64,9 @@
if ($this->apiCallPath[1] === 'namesearch') {
$name = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
$this->response($this->nameSearch($name));
} elseif ($this->apiCallPath[1] === 'akasearch') {
$aka = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
$this->response($this->akaSearch($aka));
} else {
$this->syntaxErrorMessage('Unknown Nodelist function');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment