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": { "require": {
"flashwave/index": "^0.2410", "flashwave/index": "^0.2410",
"flashii/rpcii": "^2.0", "flashwave/aiwass": "^1.1",
"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
View file

@ -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": "33116c436dc775be3d0e0b1d33114224", "content-hash": "526f12235a073ac908e932627e1a16fa",
"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": "flashii/rpcii", "name": "flashwave/aiwass",
"version": "v2.0.0", "version": "v1.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://patchii.net/flashii/rpcii-php.git", "url": "https://patchii.net/flashii/aiwass.git",
"reference": "93ec139171d023f210f0b7464266b6fc42b4d838" "reference": "cf6653ed4676d549b543eeba2b9db517c1feb356"
}, },
"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": "^2.0", "phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.4" "phpunit/phpunit": "^11.2"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"RPCii\\": "src" "Aiwass\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -451,9 +451,9 @@
"role": "mom" "role": "mom"
} }
], ],
"description": "HTTP RPC client/server library.", "description": "Shared HTTP RPC client/server library.",
"homepage": "https://railgun.sh/rpcii", "homepage": "https://railgun.sh/aiwass",
"time": "2024-11-13T23:17:29+00:00" "time": "2024-10-05T00:04:26+00:00"
}, },
{ {
"name": "flashwave/index", "name": "flashwave/index",
@ -810,20 +810,20 @@
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "3.8.2", "version": "3.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/briannesbitt/Carbon.git", "url": "https://github.com/briannesbitt/Carbon.git",
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947" "reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947", "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947", "reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"carbonphp/carbon-doctrine-types": "<100.0", "carbonphp/carbon-doctrine-types": "*",
"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-11-07T17:46:48+00:00" "time": "2024-08-19T06:22:39+00:00"
}, },
{ {
"name": "psr/clock", "name": "psr/clock",
@ -1324,16 +1324,16 @@
}, },
{ {
"name": "sentry/sentry", "name": "sentry/sentry",
"version": "4.10.0", "version": "4.9.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/getsentry/sentry-php.git", "url": "https://github.com/getsentry/sentry-php.git",
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856" "reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856", "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856", "reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"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": "^2.0.3", "guzzlehttp/promises": "^1.0|^2.0",
"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|^9.6", "phpunit/phpunit": "^8.5.14|^9.4",
"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.10.0" "source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
}, },
"funding": [ "funding": [
{ {
@ -1409,7 +1409,7 @@
"type": "custom" "type": "custom"
} }
], ],
"time": "2024-11-06T07:44:19+00:00" "time": "2024-08-08T14:40:50+00:00"
}, },
{ {
"name": "symfony/clock", "name": "symfony/clock",
@ -2739,16 +2739,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v3.14.2", "version": "v3.14.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"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.2" "source": "https://github.com/twigphp/Twig/tree/v3.14.0"
}, },
"funding": [ "funding": [
{ {
@ -2814,22 +2814,22 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-07T12:36:22+00:00" "time": "2024-09-09T17:55:12+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.12.10", "version": "1.12.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071" "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071", "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2874,7 +2874,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-11-11T15:37:09+00:00" "time": "2024-10-18T11:12:07+00:00"
} }
], ],
"aliases": [], "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 ## 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.
- [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 ## 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.

View file

@ -3,12 +3,10 @@ namespace Misuzu\Auth;
use RuntimeException; use RuntimeException;
use Misuzu\Users\{UsersContext,UserInfo}; use Misuzu\Users\{UsersContext,UserInfo};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction}; use Aiwass\Server\{RpcActionHandler,RpcProcedure};
use Index\Config\Config; use Index\Config\Config;
final class AuthRpcHandler implements RpcHandler { final class AuthRpcActions extends RpcActionHandler {
use RpcHandlerCommon;
public function __construct( public function __construct(
private Config $impersonateConfig, private Config $impersonateConfig,
private UsersContext $usersCtx, private UsersContext $usersCtx,
@ -23,7 +21,7 @@ final class AuthRpcHandler implements RpcHandler {
return in_array($targetId, $whitelist, true); return in_array($targetId, $whitelist, true);
} }
#[RpcAction('misuzu:auth:attemptMisuzuAuth')] #[RpcProcedure('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())

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\CSRF;
use Misuzu\Auth\AuthContext; use Misuzu\Auth\AuthContext;
use Misuzu\Users\{UsersContext,UserInfo}; use Misuzu\Users\{UsersContext,UserInfo};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction}; use Aiwass\Server\{RpcActionHandler,RpcProcedure};
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 HanyuuRpcHandler implements RpcHandler { final class HanyuuRpcActions extends RpcActionHandler {
use RpcHandlerCommon;
public function __construct( public function __construct(
private $getBaseUrl, private $getBaseUrl,
private Config $impersonateConfig, 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 = '') { 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.');

View file

@ -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 RPCii\HmacVerificationProvider; use Aiwass\HmacVerificationProvider;
use RPCii\Server\HttpRpcServer; use Aiwass\Server\RpcServer;
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,8 +269,7 @@ 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(
@ -282,34 +281,30 @@ class MisuzuContext {
$routingCtx->register(new LegacyRoutes($this->urls)); $routingCtx->register(new LegacyRoutes($this->urls));
$rpcServer = new HttpRpcServer; $rpcServer = new RpcServer;
$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\AuthRpcHandler( $rpcServer->register(new Auth\AuthRpcActions(
$this->config->scopeTo('impersonate'), $this->config->scopeTo('impersonate'),
$this->usersCtx, $this->usersCtx,
$this->authCtx $this->authCtx
)); ));
$rpcServer->register(new Emoticons\EmotesRpcHandler( $rpcServer->register(new Users\UsersRpcActions(
$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 HttpRpcServer; $hanyuuRpcServer = new RpcServer;
$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\HanyuuRpcHandler( $hanyuuRpcServer->register(new Hanyuu\HanyuuRpcActions(
fn() => $this->config->getString('hanyuu.endpoint'), fn() => $this->config->getString('hanyuu.endpoint'),
$this->config->scopeTo('impersonate'), $this->config->scopeTo('impersonate'),
$this->urls, $this->urls,

View file

@ -4,7 +4,6 @@ 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};
@ -26,8 +25,7 @@ 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');
} }
@ -42,8 +40,6 @@ 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 = [];

View file

@ -4,14 +4,12 @@ namespace Misuzu\Users;
use RuntimeException; use RuntimeException;
use Misuzu\SiteInfo; use Misuzu\SiteInfo;
use Misuzu\Users\Assets\UserAvatarAsset; use Misuzu\Users\Assets\UserAvatarAsset;
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcQuery}; use Aiwass\Server\{RpcActionHandler,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 UsersRpcHandler implements RpcHandler { final class UsersRpcActions extends RpcActionHandler {
use RpcHandlerCommon;
public function __construct( public function __construct(
private SiteInfo $siteInfo, private SiteInfo $siteInfo,
private UrlRegistry $urls, private UrlRegistry $urls,
@ -19,7 +17,7 @@ final class UsersRpcHandler implements RpcHandler {
) {} ) {}
#[RpcQuery('misuzu:users:getUser')] #[RpcQuery('misuzu:users:getUser')]
public function queryGetUser(string $userId, bool $includeEMailAddress = false): array { public function queryGetUser(string $userId): 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) {
@ -53,38 +51,33 @@ final class UsersRpcHandler implements RpcHandler {
$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(),
];
$output['id'] = $userInfo->getId(); if($userInfo->hasLastActive())
$output['name'] = $userInfo->getName(); $output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
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();
$output['created_at'] = $userInfo->getCreatedAt()->toIso8601ZuluString(); if($userInfo->isSuperUser())
if($userInfo->hasLastActive()) $output['is_super'] = true;
$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;