Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket server 2 #3726

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fbecc7b
NOT working
Ostico Nov 8, 2024
218739b
Merge branch 'develop' into socket-server
Ostico Nov 8, 2024
393a985
Merge branch 'develop' into socket-server
Ostico Nov 8, 2024
673f408
Base server completed
Ostico Nov 8, 2024
0ecb7da
0-ALPHA
Ostico Nov 9, 2024
d46f3ac
Fixed run script
Ostico Nov 9, 2024
3ac2f2f
Improvements
Ostico Nov 9, 2024
6093291
Checking bug on apache configuration
Ostico Nov 11, 2024
e5e7b37
Merge branch 'develop' into socket-server
Ostico Nov 11, 2024
8d95493
Testable version
Ostico Nov 11, 2024
7384f3c
Stable release
Ostico Nov 12, 2024
a7d2db9
Re-activated SocketListener Component
Ostico Nov 12, 2024
b432817
Fixed not resolved path from outside server directory
Ostico Nov 12, 2024
b37edfa
Updated submodule
Ostico Nov 12, 2024
e5e7971
Fix api token
riccio82 Nov 13, 2024
ab87226
Fixed comments delivery
Ostico Nov 13, 2024
02d32a7
Fixed test-script
Ostico Nov 13, 2024
773bbdd
Improvement on Languages class
Ostico Nov 14, 2024
2ad5310
Merge branch 'develop' into socket-server
Ostico Nov 14, 2024
feb62f5
Updates internal
Ostico Nov 26, 2024
6328e4e
Update dependency webpack to v5.96.1 (#3710)
renovate[bot] Dec 2, 2024
9b43447
Update dependency react-hotkeys-hook to v4.6.1 (#3709)
renovate[bot] Dec 2, 2024
51040ae
Update dependency eslint-plugin-testing-library to v7 (#3711)
renovate[bot] Dec 2, 2024
ce48ca7
yarn.lock update
riccio82 Dec 2, 2024
211360c
Fixed broadcast logout on password change
Ostico Dec 3, 2024
8e41f0c
Merge remote-tracking branch 'origin/develop' into socket-server
riccio82 Dec 4, 2024
d925dbb
Update yarn lock
riccio82 Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker
2 changes: 1 addition & 1 deletion internal_scripts
32 changes: 30 additions & 2 deletions lib/Controller/API/App/Authentication/LoginController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* Created by PhpStorm.
* User: fregini
* Date: 22/11/2016
* User: Domenico <[email protected]>, <[email protected]>
* Date: 19/09/2024
* Time: 09:38
*/

Expand Down Expand Up @@ -132,4 +132,32 @@ public function token() {
$this->response->code( 200 );
}

/**
* Signed Double-Submit Cookie
* @throws Exception
*/
public function socketToken() {

if ( empty( $_SESSION[ 'user' ] ) ) {
$this->response->code( 406 );
return;
}

$jwt = new SimpleJWT( [ "uid" => $_SESSION[ 'user' ]->uid ] );
$jwt->setTimeToLive( 60 );

CookieManager::setCookie( INIT::$XSRF_TOKEN, $jwt->jsonSerialize(),
[
'expires' => time() + 60, /* now + 60 seconds */
'path' => '/',
'domain' => INIT::$COOKIE_DOMAIN,
'secure' => true,
'httponly' => false,
'samesite' => 'Strict',
]
);

$this->response->code( 200 );
}

}
1 change: 1 addition & 0 deletions lib/Routes/utils_routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
route( '/login', 'POST', [ 'API\App\Authentication\LoginController', 'login' ] );
route( '/logout', 'POST', [ 'API\App\Authentication\LoginController', 'directLogout' ] );
route( '/login/token', 'GET', [ 'API\App\Authentication\LoginController', 'token' ] );
route( '/login/socket', 'GET', [ 'API\App\Authentication\LoginController', 'socketToken' ] );

route( '/metadata', 'POST', [ 'API\App\UserMetadataController', 'update' ] );

Expand Down
16 changes: 3 additions & 13 deletions lib/Utils/AsyncTasks/Workers/GlossaryWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,14 @@ private function getFeatureSetFromString( $featuresString ) {
/**
* @param FeatureSet $featureSet
*
* @return Engines_AbstractEngine
* @return Engines_MyMemory
* @throws Exception
*/
private function getEngine( FeatureSet $featureSet ) {
$_TMS = Engine::getInstance( 1 );
$_TMS->setFeatureSet( $featureSet );

/** @var Engines_MyMemory $_TMS */
return $_TMS;
}

Expand All @@ -532,17 +533,6 @@ private function getUser( $array ) {
* @throws Exception
*/
private function getMyMemoryClient() {
$engineDAO = new EnginesModel_EngineDAO( Database::obtain() );
$engineStruct = EnginesModel_EngineStruct::getStruct();
$engineStruct->id = 1;

$eng = $engineDAO->setCacheTTL( 60 * 5 )->read( $engineStruct );

/**
* @var $engineRecord EnginesModel_EngineStruct
*/
$engineRecord = @$eng[ 0 ];

return new Engines_MyMemory( $engineRecord );
return $this->getEngine( new FeatureSet() );
}
}
6 changes: 3 additions & 3 deletions lib/Utils/Langs/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function getInstance(): Languages {
*/
public static function isRTL( string $code ): bool {
//convert ISO code in RFC
$code = ( new Languages )->normalizeLanguageCode( $code );
$code = self::getInstance()->normalizeLanguageCode( $code );

return self::$map_rfc2obj[ $code ][ 'rtl' ];
}
Expand Down Expand Up @@ -342,7 +342,7 @@ protected function normalizeLanguageCode( string $languageCode ): ?string {
* @return bool
*/
public static function isValidLanguage( string $language ): bool {
$language = ( new Languages )->normalizeLanguageCode( $language );
$language = self::getInstance()->normalizeLanguageCode( $language );

return array_key_exists( $language, self::$map_rfc2obj );
}
Expand Down Expand Up @@ -374,7 +374,7 @@ public static function getLocalizedLanguage( string $rfc3066code ): ?string {
* @return string|null
*/
public static function convertLanguageToIsoCode( string $code ): ?string {
$code = ( new Languages )->normalizeLanguageCode( $code );
$code = self::getInstance()->normalizeLanguageCode( $code );

return self::$map_rfc2obj[ $code ][ 'isocode' ] ?? null;
}
Expand Down
6 changes: 3 additions & 3 deletions nodejs/enqueue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ stompit.connect(connectOptions, function(error, client) {
}

var sendHeaders = {
'destination': '/queue/matecat_sse_comments',
'destination': '/topic/matecat_sse_notifications',
'content-type': 'text/plain'
};

var frame = client.send(sendHeaders);
var response = {
_type : 'comment',
data : {
id_job : '2',
id_job : '638',
password : '3494ab77e7d7',
payload: {
_type: 'comment',
id_segment : Math.random(),
id_segment : 377916,
message : _.sample(['hello', 'hi', 'help', 'sorry'])
}
}
Expand Down
Loading