Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
39be84fcc0 | |||
242e70eabf | |||
174ceaa4e7 | |||
058b409adf | |||
8e006c7003 |
9 changed files with 131 additions and 71 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"flashwave/index": "^0.2410",
|
"flashwave/index": "^0.2410",
|
||||||
"flashwave/aiwass": "^1.1",
|
"flashii/rpcii": "^2.0",
|
||||||
"erusev/parsedown": "~1.6",
|
"erusev/parsedown": "~1.6",
|
||||||
"chillerlan/php-qrcode": "^4.3",
|
"chillerlan/php-qrcode": "^4.3",
|
||||||
"symfony/mailer": "^6.0",
|
"symfony/mailer": "^6.0",
|
||||||
|
|
72
composer.lock
generated
72
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "526f12235a073ac908e932627e1a16fa",
|
"content-hash": "33116c436dc775be3d0e0b1d33114224",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "carbonphp/carbon-doctrine-types",
|
"name": "carbonphp/carbon-doctrine-types",
|
||||||
|
@ -417,12 +417,12 @@
|
||||||
"time": "2019-12-30T22:54:17+00:00"
|
"time": "2019-12-30T22:54:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "flashwave/aiwass",
|
"name": "flashii/rpcii",
|
||||||
"version": "v1.1.0",
|
"version": "v2.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://patchii.net/flashii/aiwass.git",
|
"url": "https://patchii.net/flashii/rpcii-php.git",
|
||||||
"reference": "cf6653ed4676d549b543eeba2b9db517c1feb356"
|
"reference": "93ec139171d023f210f0b7464266b6fc42b4d838"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-msgpack": ">=2.2",
|
"ext-msgpack": ">=2.2",
|
||||||
|
@ -430,13 +430,13 @@
|
||||||
"php": ">=8.3"
|
"php": ">=8.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpstan/phpstan": "^1.11",
|
"phpstan/phpstan": "^2.0",
|
||||||
"phpunit/phpunit": "^11.2"
|
"phpunit/phpunit": "^11.4"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Aiwass\\": "src"
|
"RPCii\\": "src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
@ -451,9 +451,9 @@
|
||||||
"role": "mom"
|
"role": "mom"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Shared HTTP RPC client/server library.",
|
"description": "HTTP RPC client/server library.",
|
||||||
"homepage": "https://railgun.sh/aiwass",
|
"homepage": "https://railgun.sh/rpcii",
|
||||||
"time": "2024-10-05T00:04:26+00:00"
|
"time": "2024-11-13T23:17:29+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "flashwave/index",
|
"name": "flashwave/index",
|
||||||
|
@ -810,20 +810,20 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nesbot/carbon",
|
"name": "nesbot/carbon",
|
||||||
"version": "3.8.0",
|
"version": "3.8.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||||
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f"
|
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
|
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
|
||||||
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
|
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"carbonphp/carbon-doctrine-types": "*",
|
"carbonphp/carbon-doctrine-types": "<100.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
"psr/clock": "^1.0",
|
"psr/clock": "^1.0",
|
||||||
|
@ -912,7 +912,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-08-19T06:22:39+00:00"
|
"time": "2024-11-07T17:46:48+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/clock",
|
"name": "psr/clock",
|
||||||
|
@ -1324,16 +1324,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sentry/sentry",
|
"name": "sentry/sentry",
|
||||||
"version": "4.9.0",
|
"version": "4.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/getsentry/sentry-php.git",
|
"url": "https://github.com/getsentry/sentry-php.git",
|
||||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
|
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1351,12 +1351,12 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.4",
|
"friendsofphp/php-cs-fixer": "^3.4",
|
||||||
"guzzlehttp/promises": "^1.0|^2.0",
|
"guzzlehttp/promises": "^2.0.3",
|
||||||
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
|
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
|
||||||
"monolog/monolog": "^1.6|^2.0|^3.0",
|
"monolog/monolog": "^1.6|^2.0|^3.0",
|
||||||
"phpbench/phpbench": "^1.0",
|
"phpbench/phpbench": "^1.0",
|
||||||
"phpstan/phpstan": "^1.3",
|
"phpstan/phpstan": "^1.3",
|
||||||
"phpunit/phpunit": "^8.5.14|^9.4",
|
"phpunit/phpunit": "^8.5|^9.6",
|
||||||
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
||||||
"vimeo/psalm": "^4.17"
|
"vimeo/psalm": "^4.17"
|
||||||
},
|
},
|
||||||
|
@ -1397,7 +1397,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/getsentry/sentry-php/issues",
|
"issues": "https://github.com/getsentry/sentry-php/issues",
|
||||||
"source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
|
"source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -1409,7 +1409,7 @@
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-08-08T14:40:50+00:00"
|
"time": "2024-11-06T07:44:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/clock",
|
"name": "symfony/clock",
|
||||||
|
@ -2739,16 +2739,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.14.0",
|
"version": "v3.14.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
|
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
|
||||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2802,7 +2802,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.14.0"
|
"source": "https://github.com/twigphp/Twig/tree/v3.14.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -2814,22 +2814,22 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-09T17:55:12+00:00"
|
"time": "2024-11-07T12:36:22+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
"version": "1.12.7",
|
"version": "1.12.10",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
|
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071",
|
||||||
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
|
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2874,7 +2874,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-10-18T11:12:07+00:00"
|
"time": "2024-11-11T15:37:09+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
|
|
@ -22,7 +22,7 @@ Below are a number of links to source code repositories related to Flashii.net a
|
||||||
|
|
||||||
## First-Party Libraries
|
## First-Party Libraries
|
||||||
- [Index](https://patchii.net/flash/index): Base library used in almost any component of the website that uses PHP.
|
- [Index](https://patchii.net/flash/index): Base library used in almost any component of the website that uses PHP.
|
||||||
- [Aiwass](https://patchii.net/flashii/aiwass): Internal RPC extension, mainly used to supply data to the API gateway.
|
- [RPCii](https://patchii.net/flashii/rpcii): Internal RPC extension, mainly used to supply data to the API gateway.
|
||||||
|
|
||||||
## Historical
|
## Historical
|
||||||
- [AJAX Chat (fork)](https://patchii.net/flashii/ajax-chat): Old chat software (2013-2015). Still kept on life support for the nostalgia.
|
- [AJAX Chat (fork)](https://patchii.net/flashii/ajax-chat): Old chat software (2013-2015). Still kept on life support for the nostalgia.
|
||||||
|
|
|
@ -3,10 +3,12 @@ namespace Misuzu\Auth;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Misuzu\Users\{UsersContext,UserInfo};
|
use Misuzu\Users\{UsersContext,UserInfo};
|
||||||
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
|
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
|
||||||
use Index\Config\Config;
|
use Index\Config\Config;
|
||||||
|
|
||||||
final class AuthRpcActions extends RpcActionHandler {
|
final class AuthRpcHandler implements RpcHandler {
|
||||||
|
use RpcHandlerCommon;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private Config $impersonateConfig,
|
private Config $impersonateConfig,
|
||||||
private UsersContext $usersCtx,
|
private UsersContext $usersCtx,
|
||||||
|
@ -21,7 +23,7 @@ final class AuthRpcActions extends RpcActionHandler {
|
||||||
return in_array($targetId, $whitelist, true);
|
return in_array($targetId, $whitelist, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[RpcProcedure('misuzu:auth:attemptMisuzuAuth')]
|
#[RpcAction('misuzu:auth:attemptMisuzuAuth')]
|
||||||
public function procAttemptMisuzuAuth(string $remoteAddr, string $token): array {
|
public function procAttemptMisuzuAuth(string $remoteAddr, string $token): array {
|
||||||
$tokenInfo = $this->authCtx->createAuthTokenPacker()->unpack($token);
|
$tokenInfo = $this->authCtx->createAuthTokenPacker()->unpack($token);
|
||||||
if(!$tokenInfo->isEmpty())
|
if(!$tokenInfo->isEmpty())
|
40
src/Emoticons/EmotesRpcHandler.php
Normal file
40
src/Emoticons/EmotesRpcHandler.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
namespace Misuzu\Emoticons;
|
||||||
|
|
||||||
|
use Index\XArray;
|
||||||
|
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcQuery};
|
||||||
|
|
||||||
|
final class EmotesRpcHandler implements RpcHandler {
|
||||||
|
use RpcHandlerCommon;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private Emotes $emotes
|
||||||
|
) {}
|
||||||
|
|
||||||
|
#[RpcQuery('misuzu:emotes:all')]
|
||||||
|
public function queryAll(bool $includeId = false, bool $includeOrder = false): array {
|
||||||
|
return XArray::select(
|
||||||
|
$this->emotes->getEmotes(orderBy: 'order'),
|
||||||
|
function($emote) use ($includeId, $includeOrder) {
|
||||||
|
$info = [
|
||||||
|
'url' => $emote->getUrl(),
|
||||||
|
'strings' => XArray::select(
|
||||||
|
$this->emotes->getEmoteStrings($emote),
|
||||||
|
fn($string) => $string->getString()
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
if($includeId)
|
||||||
|
$info['id'] = $emote->getId();
|
||||||
|
if($includeOrder)
|
||||||
|
$info['order'] = $emote->getOrder();
|
||||||
|
|
||||||
|
$rank = $emote->getMinRank();
|
||||||
|
if($rank != 0)
|
||||||
|
$info['min_rank'] = $rank;
|
||||||
|
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,12 +5,14 @@ use RuntimeException;
|
||||||
use Misuzu\CSRF;
|
use Misuzu\CSRF;
|
||||||
use Misuzu\Auth\AuthContext;
|
use Misuzu\Auth\AuthContext;
|
||||||
use Misuzu\Users\{UsersContext,UserInfo};
|
use Misuzu\Users\{UsersContext,UserInfo};
|
||||||
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
|
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
|
||||||
use Index\Colour\Colour;
|
use Index\Colour\Colour;
|
||||||
use Index\Config\Config;
|
use Index\Config\Config;
|
||||||
use Index\Urls\UrlRegistry;
|
use Index\Urls\UrlRegistry;
|
||||||
|
|
||||||
final class HanyuuRpcActions extends RpcActionHandler {
|
final class HanyuuRpcHandler implements RpcHandler {
|
||||||
|
use RpcHandlerCommon;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private $getBaseUrl,
|
private $getBaseUrl,
|
||||||
private Config $impersonateConfig,
|
private Config $impersonateConfig,
|
||||||
|
@ -49,7 +51,7 @@ final class HanyuuRpcActions extends RpcActionHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[RpcProcedure('mszhau:authCheck')]
|
#[RpcAction('mszhau:authCheck')]
|
||||||
public function procAuthCheck(string $method, string $remoteAddr, string $token, string $avatars = '') {
|
public function procAuthCheck(string $method, string $remoteAddr, string $token, string $avatars = '') {
|
||||||
if($method !== 'Misuzu')
|
if($method !== 'Misuzu')
|
||||||
return self::createErrorPayload('auth:check:method', 'Requested auth method is not supported.');
|
return self::createErrorPayload('auth:check:method', 'Requested auth method is not supported.');
|
|
@ -14,8 +14,8 @@ use Misuzu\News\News;
|
||||||
use Misuzu\Perms\Permissions;
|
use Misuzu\Perms\Permissions;
|
||||||
use Misuzu\Profile\ProfileFields;
|
use Misuzu\Profile\ProfileFields;
|
||||||
use Misuzu\Users\{UsersContext,UserInfo};
|
use Misuzu\Users\{UsersContext,UserInfo};
|
||||||
use Aiwass\HmacVerificationProvider;
|
use RPCii\HmacVerificationProvider;
|
||||||
use Aiwass\Server\RpcServer;
|
use RPCii\Server\HttpRpcServer;
|
||||||
use Index\Config\Config;
|
use Index\Config\Config;
|
||||||
use Index\Db\DbConnection;
|
use Index\Db\DbConnection;
|
||||||
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
|
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
|
||||||
|
@ -269,7 +269,8 @@ class MisuzuContext {
|
||||||
$this->authCtx,
|
$this->authCtx,
|
||||||
$this->emotes,
|
$this->emotes,
|
||||||
$this->perms,
|
$this->perms,
|
||||||
$this->authInfo
|
$this->authInfo,
|
||||||
|
$this->counters
|
||||||
));
|
));
|
||||||
|
|
||||||
$routingCtx->register(new \Misuzu\Satori\SatoriRoutes(
|
$routingCtx->register(new \Misuzu\Satori\SatoriRoutes(
|
||||||
|
@ -281,30 +282,34 @@ class MisuzuContext {
|
||||||
|
|
||||||
$routingCtx->register(new LegacyRoutes($this->urls));
|
$routingCtx->register(new LegacyRoutes($this->urls));
|
||||||
|
|
||||||
$rpcServer = new RpcServer;
|
$rpcServer = new HttpRpcServer;
|
||||||
$routingCtx->getRouter()->register($rpcServer->createRouteHandler(
|
$routingCtx->getRouter()->register($rpcServer->createRouteHandler(
|
||||||
new HmacVerificationProvider(fn() => $this->config->getString('aleister.secret'))
|
new HmacVerificationProvider(fn() => $this->config->getString('aleister.secret'))
|
||||||
));
|
));
|
||||||
|
|
||||||
$rpcServer->register(new Auth\AuthRpcActions(
|
$rpcServer->register(new Auth\AuthRpcHandler(
|
||||||
$this->config->scopeTo('impersonate'),
|
$this->config->scopeTo('impersonate'),
|
||||||
$this->usersCtx,
|
$this->usersCtx,
|
||||||
$this->authCtx
|
$this->authCtx
|
||||||
));
|
));
|
||||||
|
|
||||||
$rpcServer->register(new Users\UsersRpcActions(
|
$rpcServer->register(new Emoticons\EmotesRpcHandler(
|
||||||
|
$this->emotes
|
||||||
|
));
|
||||||
|
|
||||||
|
$rpcServer->register(new Users\UsersRpcHandler(
|
||||||
$this->siteInfo,
|
$this->siteInfo,
|
||||||
$this->urls,
|
$this->urls,
|
||||||
$this->usersCtx
|
$this->usersCtx
|
||||||
));
|
));
|
||||||
|
|
||||||
// This RPC server will eventually despawn when Hanyuu fully owns auth
|
// This RPC server will eventually despawn when Hanyuu fully owns auth
|
||||||
$hanyuuRpcServer = new RpcServer;
|
$hanyuuRpcServer = new HttpRpcServer;
|
||||||
$routingCtx->getRouter()->scopeTo('/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
|
$routingCtx->getRouter()->scopeTo('/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
|
||||||
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
|
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
|
||||||
));
|
));
|
||||||
|
|
||||||
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcActions(
|
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcHandler(
|
||||||
fn() => $this->config->getString('hanyuu.endpoint'),
|
fn() => $this->config->getString('hanyuu.endpoint'),
|
||||||
$this->config->scopeTo('impersonate'),
|
$this->config->scopeTo('impersonate'),
|
||||||
$this->urls,
|
$this->urls,
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Misuzu\SharpChat;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Misuzu\RoutingContext;
|
use Misuzu\RoutingContext;
|
||||||
use Misuzu\Auth\{AuthContext,AuthInfo,Sessions};
|
use Misuzu\Auth\{AuthContext,AuthInfo,Sessions};
|
||||||
|
use Misuzu\Counters\Counters;
|
||||||
use Misuzu\Emoticons\Emotes;
|
use Misuzu\Emoticons\Emotes;
|
||||||
use Misuzu\Perms\Permissions;
|
use Misuzu\Perms\Permissions;
|
||||||
use Misuzu\Users\{Bans,UsersContext,UserInfo};
|
use Misuzu\Users\{Bans,UsersContext,UserInfo};
|
||||||
|
@ -25,7 +26,8 @@ final class SharpChatRoutes implements RouteHandler {
|
||||||
private AuthContext $authCtx,
|
private AuthContext $authCtx,
|
||||||
private Emotes $emotes,
|
private Emotes $emotes,
|
||||||
private Permissions $perms,
|
private Permissions $perms,
|
||||||
private AuthInfo $authInfo
|
private AuthInfo $authInfo,
|
||||||
|
private Counters $counters
|
||||||
) {
|
) {
|
||||||
$this->hashKey = $this->config->getString('hashKey', 'woomy');
|
$this->hashKey = $this->config->getString('hashKey', 'woomy');
|
||||||
}
|
}
|
||||||
|
@ -40,6 +42,8 @@ final class SharpChatRoutes implements RouteHandler {
|
||||||
if($request->getMethod() === 'OPTIONS')
|
if($request->getMethod() === 'OPTIONS')
|
||||||
return 204;
|
return 204;
|
||||||
|
|
||||||
|
$this->counters->increment('dev:legacy_emotes_loads');
|
||||||
|
|
||||||
$emotes = $this->emotes->getEmotes(orderBy: 'order');
|
$emotes = $this->emotes->getEmotes(orderBy: 'order');
|
||||||
$out = [];
|
$out = [];
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,14 @@ namespace Misuzu\Users;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Misuzu\SiteInfo;
|
use Misuzu\SiteInfo;
|
||||||
use Misuzu\Users\Assets\UserAvatarAsset;
|
use Misuzu\Users\Assets\UserAvatarAsset;
|
||||||
use Aiwass\Server\{RpcActionHandler,RpcQuery};
|
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcQuery};
|
||||||
use Index\XArray;
|
use Index\XArray;
|
||||||
use Index\Colour\{Colour,ColourRgb};
|
use Index\Colour\{Colour,ColourRgb};
|
||||||
use Index\Urls\UrlRegistry;
|
use Index\Urls\UrlRegistry;
|
||||||
|
|
||||||
final class UsersRpcActions extends RpcActionHandler {
|
final class UsersRpcHandler implements RpcHandler {
|
||||||
|
use RpcHandlerCommon;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private SiteInfo $siteInfo,
|
private SiteInfo $siteInfo,
|
||||||
private UrlRegistry $urls,
|
private UrlRegistry $urls,
|
||||||
|
@ -17,7 +19,7 @@ final class UsersRpcActions extends RpcActionHandler {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[RpcQuery('misuzu:users:getUser')]
|
#[RpcQuery('misuzu:users:getUser')]
|
||||||
public function queryGetUser(string $userId): array {
|
public function queryGetUser(string $userId, bool $includeEMailAddress = false): array {
|
||||||
try {
|
try {
|
||||||
$userInfo = $this->usersCtx->getUserInfo($userId, Users::GET_USER_ID);
|
$userInfo = $this->usersCtx->getUserInfo($userId, Users::GET_USER_ID);
|
||||||
} catch(RuntimeException) {
|
} catch(RuntimeException) {
|
||||||
|
@ -51,33 +53,38 @@ final class UsersRpcActions extends RpcActionHandler {
|
||||||
|
|
||||||
$avatars = array_reverse($avatars);
|
$avatars = array_reverse($avatars);
|
||||||
|
|
||||||
$output = [
|
$output = [];
|
||||||
'id' => $userInfo->getId(),
|
|
||||||
'name' => $userInfo->getName(),
|
|
||||||
'colour_raw' => $colourRaw,
|
|
||||||
'colour_css' => $colourCSS,
|
|
||||||
'rank' => $rank,
|
|
||||||
'country_code' => $userInfo->getCountryCode(),
|
|
||||||
'avatar_urls' => $avatars,
|
|
||||||
'profile_url' => $baseUrl . $this->urls->format('user-profile', ['user' => $userInfo->getId()]),
|
|
||||||
'created_at' => $userInfo->getCreatedAt()->toIso8601ZuluString(),
|
|
||||||
];
|
|
||||||
|
|
||||||
if($userInfo->hasLastActive())
|
$output['id'] = $userInfo->getId();
|
||||||
$output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
|
$output['name'] = $userInfo->getName();
|
||||||
|
if($includeEMailAddress)
|
||||||
|
$output['email'] = $userInfo->getEMailAddress();
|
||||||
|
|
||||||
|
$output['colour_raw'] = $colourRaw;
|
||||||
|
$output['colour_css'] = $colourCSS;
|
||||||
|
$output['rank'] = $rank;
|
||||||
|
$output['country_code'] = $userInfo->getCountryCode();
|
||||||
|
|
||||||
$roles = XArray::select(
|
$roles = XArray::select(
|
||||||
$this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true),
|
$this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true),
|
||||||
fn($roleInfo) => $roleInfo->getString(),
|
fn($roleInfo) => $roleInfo->getString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!empty($roles))
|
if(!empty($roles))
|
||||||
$output['roles'] = $roles;
|
$output['roles'] = $roles;
|
||||||
|
if($userInfo->isSuperUser())
|
||||||
|
$output['is_super'] = true;
|
||||||
|
|
||||||
if($userInfo->hasTitle())
|
if($userInfo->hasTitle())
|
||||||
$output['title'] = $userInfo->getTitle();
|
$output['title'] = $userInfo->getTitle();
|
||||||
|
|
||||||
if($userInfo->isSuperUser())
|
$output['created_at'] = $userInfo->getCreatedAt()->toIso8601ZuluString();
|
||||||
$output['is_super'] = true;
|
if($userInfo->hasLastActive())
|
||||||
|
$output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
|
||||||
|
|
||||||
|
$output['profile_url'] = $baseUrl . $this->urls->format('user-profile', ['user' => $userInfo->getId()]);
|
||||||
|
$output['avatar_urls'] = $avatars;
|
||||||
|
|
||||||
if($userInfo->isDeleted())
|
if($userInfo->isDeleted())
|
||||||
$output['is_deleted'] = true;
|
$output['is_deleted'] = true;
|
||||||
|
|
Loading…
Reference in a new issue