Compare commits

..

No commits in common. "master" and "20241107" have entirely different histories.

9 changed files with 71 additions and 131 deletions

View file

@ -1,7 +1,7 @@
{
"require": {
"flashwave/index": "^0.2410",
"flashii/rpcii": "^2.0",
"flashwave/aiwass": "^1.1",
"erusev/parsedown": "~1.6",
"chillerlan/php-qrcode": "^4.3",
"symfony/mailer": "^6.0",

72
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "33116c436dc775be3d0e0b1d33114224",
"content-hash": "526f12235a073ac908e932627e1a16fa",
"packages": [
{
"name": "carbonphp/carbon-doctrine-types",
@ -417,12 +417,12 @@
"time": "2019-12-30T22:54:17+00:00"
},
{
"name": "flashii/rpcii",
"version": "v2.0.0",
"name": "flashwave/aiwass",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://patchii.net/flashii/rpcii-php.git",
"reference": "93ec139171d023f210f0b7464266b6fc42b4d838"
"url": "https://patchii.net/flashii/aiwass.git",
"reference": "cf6653ed4676d549b543eeba2b9db517c1feb356"
},
"require": {
"ext-msgpack": ">=2.2",
@ -430,13 +430,13 @@
"php": ">=8.3"
},
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.4"
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.2"
},
"type": "library",
"autoload": {
"psr-4": {
"RPCii\\": "src"
"Aiwass\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -451,9 +451,9 @@
"role": "mom"
}
],
"description": "HTTP RPC client/server library.",
"homepage": "https://railgun.sh/rpcii",
"time": "2024-11-13T23:17:29+00:00"
"description": "Shared HTTP RPC client/server library.",
"homepage": "https://railgun.sh/aiwass",
"time": "2024-10-05T00:04:26+00:00"
},
{
"name": "flashwave/index",
@ -810,20 +810,20 @@
},
{
"name": "nesbot/carbon",
"version": "3.8.2",
"version": "3.8.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947"
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"shasum": ""
},
"require": {
"carbonphp/carbon-doctrine-types": "<100.0",
"carbonphp/carbon-doctrine-types": "*",
"ext-json": "*",
"php": "^8.1",
"psr/clock": "^1.0",
@ -912,7 +912,7 @@
"type": "tidelift"
}
],
"time": "2024-11-07T17:46:48+00:00"
"time": "2024-08-19T06:22:39+00:00"
},
{
"name": "psr/clock",
@ -1324,16 +1324,16 @@
},
{
"name": "sentry/sentry",
"version": "4.10.0",
"version": "4.9.0",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"shasum": ""
},
"require": {
@ -1351,12 +1351,12 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"guzzlehttp/promises": "^2.0.3",
"guzzlehttp/promises": "^1.0|^2.0",
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
"monolog/monolog": "^1.6|^2.0|^3.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^8.5|^9.6",
"phpunit/phpunit": "^8.5.14|^9.4",
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
"vimeo/psalm": "^4.17"
},
@ -1397,7 +1397,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
"source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
},
"funding": [
{
@ -1409,7 +1409,7 @@
"type": "custom"
}
],
"time": "2024-11-06T07:44:19+00:00"
"time": "2024-08-08T14:40:50+00:00"
},
{
"name": "symfony/clock",
@ -2739,16 +2739,16 @@
},
{
"name": "twig/twig",
"version": "v3.14.2",
"version": "v3.14.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a"
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"shasum": ""
},
"require": {
@ -2802,7 +2802,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.14.2"
"source": "https://github.com/twigphp/Twig/tree/v3.14.0"
},
"funding": [
{
@ -2814,22 +2814,22 @@
"type": "tidelift"
}
],
"time": "2024-11-07T12:36:22+00:00"
"time": "2024-09-09T17:55:12+00:00"
}
],
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.12.10",
"version": "1.12.7",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071"
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071",
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"shasum": ""
},
"require": {
@ -2874,7 +2874,7 @@
"type": "github"
}
],
"time": "2024-11-11T15:37:09+00:00"
"time": "2024-10-18T11:12:07+00:00"
}
],
"aliases": [],

View file

@ -22,7 +22,7 @@ Below are a number of links to source code repositories related to Flashii.net a
## First-Party Libraries
- [Index](https://patchii.net/flash/index): Base library used in almost any component of the website that uses PHP.
- [RPCii](https://patchii.net/flashii/rpcii): Internal RPC extension, mainly used to supply data to the API gateway.
- [Aiwass](https://patchii.net/flashii/aiwass): Internal RPC extension, mainly used to supply data to the API gateway.
## Historical
- [AJAX Chat (fork)](https://patchii.net/flashii/ajax-chat): Old chat software (2013-2015). Still kept on life support for the nostalgia.

View file

@ -3,12 +3,10 @@ namespace Misuzu\Auth;
use RuntimeException;
use Misuzu\Users\{UsersContext,UserInfo};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
use Index\Config\Config;
final class AuthRpcHandler implements RpcHandler {
use RpcHandlerCommon;
final class AuthRpcActions extends RpcActionHandler {
public function __construct(
private Config $impersonateConfig,
private UsersContext $usersCtx,
@ -23,7 +21,7 @@ final class AuthRpcHandler implements RpcHandler {
return in_array($targetId, $whitelist, true);
}
#[RpcAction('misuzu:auth:attemptMisuzuAuth')]
#[RpcProcedure('misuzu:auth:attemptMisuzuAuth')]
public function procAttemptMisuzuAuth(string $remoteAddr, string $token): array {
$tokenInfo = $this->authCtx->createAuthTokenPacker()->unpack($token);
if(!$tokenInfo->isEmpty())

View file

@ -1,40 +0,0 @@
<?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;
}
);
}
}

View file

@ -5,14 +5,12 @@ use RuntimeException;
use Misuzu\CSRF;
use Misuzu\Auth\AuthContext;
use Misuzu\Users\{UsersContext,UserInfo};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
use Index\Colour\Colour;
use Index\Config\Config;
use Index\Urls\UrlRegistry;
final class HanyuuRpcHandler implements RpcHandler {
use RpcHandlerCommon;
final class HanyuuRpcActions extends RpcActionHandler {
public function __construct(
private $getBaseUrl,
private Config $impersonateConfig,
@ -51,7 +49,7 @@ final class HanyuuRpcHandler implements RpcHandler {
);
}
#[RpcAction('mszhau:authCheck')]
#[RpcProcedure('mszhau:authCheck')]
public function procAuthCheck(string $method, string $remoteAddr, string $token, string $avatars = '') {
if($method !== 'Misuzu')
return self::createErrorPayload('auth:check:method', 'Requested auth method is not supported.');

View file

@ -14,8 +14,8 @@ use Misuzu\News\News;
use Misuzu\Perms\Permissions;
use Misuzu\Profile\ProfileFields;
use Misuzu\Users\{UsersContext,UserInfo};
use RPCii\HmacVerificationProvider;
use RPCii\Server\HttpRpcServer;
use Aiwass\HmacVerificationProvider;
use Aiwass\Server\RpcServer;
use Index\Config\Config;
use Index\Db\DbConnection;
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
@ -269,8 +269,7 @@ class MisuzuContext {
$this->authCtx,
$this->emotes,
$this->perms,
$this->authInfo,
$this->counters
$this->authInfo
));
$routingCtx->register(new \Misuzu\Satori\SatoriRoutes(
@ -282,34 +281,30 @@ class MisuzuContext {
$routingCtx->register(new LegacyRoutes($this->urls));
$rpcServer = new HttpRpcServer;
$rpcServer = new RpcServer;
$routingCtx->getRouter()->register($rpcServer->createRouteHandler(
new HmacVerificationProvider(fn() => $this->config->getString('aleister.secret'))
));
$rpcServer->register(new Auth\AuthRpcHandler(
$rpcServer->register(new Auth\AuthRpcActions(
$this->config->scopeTo('impersonate'),
$this->usersCtx,
$this->authCtx
));
$rpcServer->register(new Emoticons\EmotesRpcHandler(
$this->emotes
));
$rpcServer->register(new Users\UsersRpcHandler(
$rpcServer->register(new Users\UsersRpcActions(
$this->siteInfo,
$this->urls,
$this->usersCtx
));
// This RPC server will eventually despawn when Hanyuu fully owns auth
$hanyuuRpcServer = new HttpRpcServer;
$hanyuuRpcServer = new RpcServer;
$routingCtx->getRouter()->scopeTo('/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
));
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcHandler(
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcActions(
fn() => $this->config->getString('hanyuu.endpoint'),
$this->config->scopeTo('impersonate'),
$this->urls,

View file

@ -4,7 +4,6 @@ namespace Misuzu\SharpChat;
use RuntimeException;
use Misuzu\RoutingContext;
use Misuzu\Auth\{AuthContext,AuthInfo,Sessions};
use Misuzu\Counters\Counters;
use Misuzu\Emoticons\Emotes;
use Misuzu\Perms\Permissions;
use Misuzu\Users\{Bans,UsersContext,UserInfo};
@ -26,8 +25,7 @@ final class SharpChatRoutes implements RouteHandler {
private AuthContext $authCtx,
private Emotes $emotes,
private Permissions $perms,
private AuthInfo $authInfo,
private Counters $counters
private AuthInfo $authInfo
) {
$this->hashKey = $this->config->getString('hashKey', 'woomy');
}
@ -42,8 +40,6 @@ final class SharpChatRoutes implements RouteHandler {
if($request->getMethod() === 'OPTIONS')
return 204;
$this->counters->increment('dev:legacy_emotes_loads');
$emotes = $this->emotes->getEmotes(orderBy: 'order');
$out = [];

View file

@ -4,14 +4,12 @@ namespace Misuzu\Users;
use RuntimeException;
use Misuzu\SiteInfo;
use Misuzu\Users\Assets\UserAvatarAsset;
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcQuery};
use Aiwass\Server\{RpcActionHandler,RpcQuery};
use Index\XArray;
use Index\Colour\{Colour,ColourRgb};
use Index\Urls\UrlRegistry;
final class UsersRpcHandler implements RpcHandler {
use RpcHandlerCommon;
final class UsersRpcActions extends RpcActionHandler {
public function __construct(
private SiteInfo $siteInfo,
private UrlRegistry $urls,
@ -19,7 +17,7 @@ final class UsersRpcHandler implements RpcHandler {
) {}
#[RpcQuery('misuzu:users:getUser')]
public function queryGetUser(string $userId, bool $includeEMailAddress = false): array {
public function queryGetUser(string $userId): array {
try {
$userInfo = $this->usersCtx->getUserInfo($userId, Users::GET_USER_ID);
} catch(RuntimeException) {
@ -53,38 +51,33 @@ final class UsersRpcHandler implements RpcHandler {
$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(),
];
$output['id'] = $userInfo->getId();
$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();
if($userInfo->hasLastActive())
$output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
$roles = XArray::select(
$this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true),
fn($roleInfo) => $roleInfo->getString(),
);
if(!empty($roles))
$output['roles'] = $roles;
if($userInfo->isSuperUser())
$output['is_super'] = true;
if($userInfo->hasTitle())
$output['title'] = $userInfo->getTitle();
$output['created_at'] = $userInfo->getCreatedAt()->toIso8601ZuluString();
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->isSuperUser())
$output['is_super'] = true;
if($userInfo->isDeleted())
$output['is_deleted'] = true;