Skip to content

Commit

Permalink
Merge branch 'develop' into space-placeholder-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ostico authored Aug 29, 2024
2 parents 84c5355 + e0f70a6 commit 716ccdb
Show file tree
Hide file tree
Showing 38 changed files with 1,214 additions and 526 deletions.
10 changes: 5 additions & 5 deletions INSTALL/INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ INSTALL.TXT
===========

Server side requirements
- Apache 2 + MySql (version >= 5.1) + PHP 5 (version >= 5.3) + PHP 5 CLI (version >= 5.3)
- Apache 2 + MySql (version >= 5.1) + PHP 7 (version >= 7.4) + PHP 5 CLI (version >= 7.4)
- Apache htaccess enabled
- Apache rewrite module installed
- Apache filter module installed
- Apache deflate module installed
- Apache headers module installed
- PHP5 JSON ( php5-json ) module installed ( For PHP Versions >= 5.5 ). N.B.: Apache needs to be restarted to apply changes
- PHP7 JSON ( php7-json ) module installed ( For PHP Versions >= 7.4 ). N.B.: Apache needs to be restarted to apply changes
- PHP magic_quotes_gpc off
- PHP cURL lib
- Edit php.ini and set at least:
Expand Down Expand Up @@ -81,11 +81,11 @@ Instructions (based on a Debian distro)
7) enable the new virtualhost
a2enmod matecat.conf
8) set php magic quotes off
edit /etc/php5/apache2/php.ini ---> magic_quotes_runtime = Off
edit /etc/php/7.4/cli/php.ini ---> magic_quotes_runtime = Off
9) restart apache
apache2ctl restart
10) enable pcntl in php5 CLI php.ini by removing pcntl functions from
disable_functions in /etc/php5/cli/php.ini
10) enable pcntl in php7 CLI php.ini by removing pcntl functions from
disable_functions in /etc/php/7.4/cli/php.ini

11)If you don't have a client id and client secret, please visit
Google Developers Console (https://console.developers.google.com/)
Expand Down
297 changes: 149 additions & 148 deletions INSTALL/matecat.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker
145 changes: 41 additions & 104 deletions inc/task_manager_config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,178 +15,115 @@ loggerName = 'TaskManager.log' ;Master Logger for the Task Manager
;;###### Key Name P1 #####
;;##############################
P1[queue_name] = "analysis_queue_P1" ;AMQ queue name
P1[pid_set_name] = "ch_pid_set_p1" ;Redis set list for the processes id
P1[max_executors] = 10 ;Number of executors
P1[redis_key] = "p1_list" ;Redis list of MateCat projects to be analyzed
P1[loggerName] = "tm_analysis_P1.log" ;Logger name
P1[max_executors] = 10 ;Number of executors
;;##############################
;;###### Key Name P2 #####
;;##############################
P2[queue_name] = "analysis_queue_P2"
P2[pid_set_name] = "ch_pid_set_p2"
P2[max_executors] = 5
P2[redis_key] = "p2_list"
P2[loggerName] = "tm_analysis_P2.log"
;;##############################
;;###### Key Name P3 #####
;;##############################
P3[queue_name] = "analysis_queue_P3"
P3[pid_set_name] = "ch_pid_set_p3"
P3[max_executors] = 1
P3[redis_key] = "p3_list"
P3[loggerName] = "tm_analysis_P3.log"

;;##################################
;;##### Key Name project_queue #####
;;##################################
PROJECT_QUEUE[queue_name] = "project_queue"
PROJECT_QUEUE[pid_set_name] = "ch_pid_project_queue"
PROJECT_QUEUE[max_executors] = 1
PROJECT_QUEUE[redis_key] = "project_queue_list"
PROJECT_QUEUE[loggerName] = "project_queue.log"
P3[max_executors] = 5
;;##############################
;;###### Key Name P4 #####
;;##############################
P4[queue_name] = "analysis_queue_P4"
P4[max_executors] = 5

;;##############################
;;##### Key Name MailQueue #####
;;##############################
MAIL[queue_name] = "mail_queue"
MAIL[pid_set_name] = "ch_pid_set_mail"
MAIL[max_executors] = 1
MAIL[redis_key] = "mail_list"
MAIL[loggerName] = "mail_queue.log"
MAIL[max_executors] = 0

;;##############################
;;##### Key Name setContribution #####
;;##############################
CONTRIBUTION[queue_name] = "set_contribution"
CONTRIBUTION[pid_set_name] = "ch_pid_set_contribution"
CONTRIBUTION[max_executors] = 1
CONTRIBUTION[redis_key] = "set_contribution_list"
CONTRIBUTION[loggerName] = "set_contribution.log"
CONTRIBUTION[max_executors] = 5

;;##############################
;;##### Key Name setContribution #####
;;##############################
CONTRIBUTION_GET[queue_name] = "get_contribution"
CONTRIBUTION_GET[max_executors] = 5

;;##############################
;;##### Key Name QAChecks #####
;;##############################
QA_CHECKS[queue_name] = "qa_checks"
QA_CHECKS[pid_set_name] = "qa_checks_set"
QA_CHECKS[max_executors] = 1
QA_CHECKS[redis_key] = "qa_checks_key"
QA_CHECKS[loggerName] = "qa_checks.log"

;;#################################
;;##############################
;;##### Key Name activity_log #####
;;#################################
;;##############################
ACTIVITYLOG[queue_name] = "activity_log"
ACTIVITYLOG[pid_set_name] = "ch_pid_activity_log"
ACTIVITYLOG[max_executors] = 1
ACTIVITYLOG[redis_key] = "activity_log_list"
ACTIVITYLOG[loggerName] = "activity_log.log"

;;##############################
;;##### Key Name DQF #####
;;##############################
DQF[queue_name] = "dqf"
DQF[pid_set_name] = "ch_pid_dqf"
DQF[max_executors] = 1
DQF[redis_key] = "dqf_list"
DQF[loggerName] = "dqf.log"

;;##################################
;;##### Key Name project_queue #####
;;##################################
PROJECT_QUEUE[queue_name] = "project_queue"
PROJECT_QUEUE[max_executors] = 1

;;######################################
;;##############################
;;##### Key Name setContributionMT #####
;;######################################
;;##############################
CONTRIBUTION_MT[queue_name] = "set_contribution_mt"
CONTRIBUTION_MT[pid_set_name] = "ch_pid_set_contribution_mt"
CONTRIBUTION_MT[max_executors] = 1
CONTRIBUTION_MT[redis_key] = "set_contribution_mt_list"
CONTRIBUTION_MT[loggerName] = "set_contribution_mt.log"
CONTRIBUTION_MT[max_executors] = 5

;;##############################
;;##### Key Name jobs #####
;;##############################
JOBS[queue_name] = "jobs"
JOBS[pid_set_name] = "ch_pid_jobs"
JOBS[max_executors] = 1
JOBS[redis_key] = "jobs_list"
JOBS[loggerName] = "jobs.log"

;;##################################
;;##### Key Name GlossaryRead #####
;;##################################
GLOSSARY_READ[queue_name] = "glossary_read"
GLOSSARY_READ[max_executors] = 5

;;###############################
;;##### Key Name tmx import #####
;;###############################
;ALIGNER_TMX_IMPORT[queue_name] = "aligner_tmx_import"
;ALIGNER_TMX_IMPORT[pid_set_name] = "ch_pid_tmx_import"
;ALIGNER_TMX_IMPORT[max_executors] = 1
;ALIGNER_TMX_IMPORT[redis_key] = "tmx_import_list"
;ALIGNER_TMX_IMPORT[loggerName] = "tmx_import.log"

;;##############################
;;##### Key Name setContribution #####
;;##############################
CONTRIBUTION_GET[queue_name] = "get_contribution"
CONTRIBUTION_GET[pid_set_name] = "ch_pid_get_contribution"
CONTRIBUTION_GET[max_executors] = 50
CONTRIBUTION_GET[redis_key] = "get_contribution_list"
CONTRIBUTION_GET[loggerName] = "get_contribution.log"
;;###################################
;;##### Key Name GlossaryWrite #####
;;###################################
GLOSSARY_WRITE[queue_name] = "glossary_write"
GLOSSARY_WRITE[max_executors] = 1

;;###############################
;;##### Align Job Small #####
;;###############################
ALIGNER_ALIGN_JOB_SMALL[queue_name] = "aligner_align_job_small"
ALIGNER_ALIGN_JOB_SMALL[pid_set_name] = "ch_pid_align_job_small"
ALIGNER_ALIGN_JOB_SMALL[max_executors] = 1
ALIGNER_ALIGN_JOB_SMALL[redis_key] = "align_job_small_list"
ALIGNER_ALIGN_JOB_SMALL[loggerName] = "align_job_small.log"

;;###############################
;;##### Align Job Medium #####
;;###############################
ALIGNER_ALIGN_JOB_MEDIUM[queue_name] = "aligner_align_job_medium"
ALIGNER_ALIGN_JOB_MEDIUM[pid_set_name] = "ch_pid_align_job_medium"
ALIGNER_ALIGN_JOB_MEDIUM[max_executors] = 1
ALIGNER_ALIGN_JOB_MEDIUM[redis_key] = "align_job_medium_list"
ALIGNER_ALIGN_JOB_MEDIUM[loggerName] = "align_job_medium.log"

;;###############################
;;##### Align Job Big #####
;;###############################
ALIGNER_ALIGN_JOB_BIG[queue_name] = "aligner_align_job_big"
ALIGNER_ALIGN_JOB_BIG[pid_set_name] = "ch_pid_align_job_big"
ALIGNER_ALIGN_JOB_BIG[max_executors] = 1
ALIGNER_ALIGN_JOB_BIG[redis_key] = "align_job_big_list"
ALIGNER_ALIGN_JOB_BIG[loggerName] = "align_job_big.log"

;;###############################
;;##### Segment Create #####
;;###############################
ALIGNER_SEGMENT_CREATE[queue_name] = "aligner_segment_create"
ALIGNER_SEGMENT_CREATE[pid_set_name] = "ch_pid_aligner_segment_create"
ALIGNER_SEGMENT_CREATE[max_executors] = 5
ALIGNER_SEGMENT_CREATE[redis_key] = "aligner_segment_create_list"
ALIGNER_SEGMENT_CREATE[loggerName] = "aligner_segment_create.log"

;;##################################
;;##### Key Name GlossaryRead #####
;;##################################
GLOSSARY_READ[queue_name] = "glossary_read"
GLOSSARY_READ[pid_set_name] = "ch_pid_glossary_read"
GLOSSARY_READ[max_executors] = 1
GLOSSARY_READ[redis_key] = "glossary_read"
GLOSSARY_READ[loggerName] = "glossary_read.log"

;;###################################
;;##### Key Name GlossaryWrite #####
;;###################################
GLOSSARY_WRITE[queue_name] = "glossary_write"
GLOSSARY_WRITE[pid_set_name] = "ch_pid_glossary_write"
GLOSSARY_WRITE[max_executors] = 1
GLOSSARY_WRITE[redis_key] = "glossary_write"
GLOSSARY_WRITE[loggerName] = "glossary_write.log"
;;###############################
;;##### Key Name tmx import #####
;;###############################
ALIGNER_TMX_IMPORT[queue_name] = "aligner_tmx_import"
ALIGNER_TMX_IMPORT[max_executors] = 1

;;###################################
;;##### AI Assistant #####
;;###################################
AI_ASSISTANT_EXPLAIN_MEANING[queue_name] = "ai_assistant_explain_meaning"
AI_ASSISTANT_EXPLAIN_MEANING[pid_set_name] = "ch_pid_ai_assistant_explain_meaning"
AI_ASSISTANT_EXPLAIN_MEANING[max_executors] = 1
AI_ASSISTANT_EXPLAIN_MEANING[redis_key] = "ai_assistant_explain_meaning"
AI_ASSISTANT_EXPLAIN_MEANING[loggerName] = "ai_assistant_explain_meaning.log"
AI_ASSISTANT_EXPLAIN_MEANING[max_executors] = 1
2 changes: 1 addition & 1 deletion inc/version.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MATECAT_VERSION]
version = "v2.22.20"
version = "v2.22.21"
2 changes: 1 addition & 1 deletion internal_scripts
70 changes: 44 additions & 26 deletions lib/Controller/API/App/GlossaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,23 @@ public function check()
{
$jsonSchemaPath = __DIR__ . '/../../../../inc/validation/schema/glossary/check.json';
$json = $this->createThePayloadForWorker($jsonSchemaPath);
$json['tmKeys'] = $this->keysBelongingToJobOwner($json['tmKeys']);

// filter the keys sent by the FE
$tmKeys = $json['tmKeys'];
$json['keys'] = array_filter($json['keys'], function($el) use($tmKeys) {
foreach($tmKeys as $tmKey){
if($tmKey['key'] === $el){
return true;
}
}

$keys = [];

foreach($json['tmKeys'] as $tmKey){
$keys[] = $tmKey['key'];
}

$json['keys'] = $keys;
return false;
});

$params = [
'action' => 'check',
'payload' => $json,
'action' => 'check',
'payload' => $json,
];

$this->enqueueWorker( self::GLOSSARY_READ, $params );
Expand Down Expand Up @@ -108,23 +113,7 @@ public function get()
{
$jsonSchemaPath = __DIR__ . '/../../../../inc/validation/schema/glossary/get.json' ;
$json = $this->createThePayloadForWorker($jsonSchemaPath);

$tmKeys = [];

foreach ($json['tmKeys'] as $tmKey){

// allowing only terms belonging to the owner of the job
if($tmKey['owner'] == true){
$tmKeys[] = $tmKey;
}

// additional terms are also visible for the other users (NOT the owner of the job) who added them
if($this->userIsLogged() and ($this->user->uid == $tmKey['uid_transl'] or $this->user->uid == $tmKey['uid_rev'])){
$tmKeys[] = $tmKey;
}
}

$json['tmKeys'] = $tmKeys;
$json['tmKeys'] = $this->keysBelongingToJobOwner($json['tmKeys']);

$params = [
'action' => 'get',
Expand Down Expand Up @@ -174,6 +163,7 @@ public function search()
{
$jsonSchemaPath = __DIR__ . '/../../../../inc/validation/schema/glossary/search.json' ;
$json = $this->createThePayloadForWorker($jsonSchemaPath);
$json['tmKeys'] = $this->keysBelongingToJobOwner($json['tmKeys']);

$params = [
'action' => 'search',
Expand Down Expand Up @@ -308,6 +298,34 @@ private function createThePayloadForWorker($jsonSchemaPath)
return $json;
}

/**
* @param $tmKeys
* @return array
*/
private function keysBelongingToJobOwner($tmKeys)
{
$return = [];

foreach ($tmKeys as $tmKey){

// allowing only terms with read permission
if( isset($tmKey['r']) and $tmKey['r'] == 1 ){

// allowing only terms belonging to the owner of the job
if(isset($tmKey['owner']) and $tmKey['owner'] == true){
$return[] = $tmKey;
}

// additional terms are also visible for the other users (NOT the owner of the job) who added them
if( $this->userIsLogged() and ($this->user->uid == $tmKey['uid_transl'] or $this->user->uid == $tmKey['uid_rev'])){
$return[] = $tmKey;
}
}
}

return $return;
}

/**
* @param array $keys
* @param \TmKeyManagement_ClientTmKeyStruct[] $userKeys
Expand Down
20 changes: 15 additions & 5 deletions lib/Controller/API/App/SignupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,28 @@ class SignupController extends AbstractStatefulKleinController {
public function create() {

$user = $this->request->param( 'user' );
$userIp = Utils::getRealIpAddr();

$checkRateLimit = $this->checkRateLimitResponse( $this->response, $user[ 'email' ], '/api/app/user' );
if ( $checkRateLimit instanceof Response ) {
$this->response = $checkRateLimit;
// rate limit on email
$checkRateLimitOnEmail = $this->checkRateLimitResponse( $this->response, $user[ 'email' ], '/api/app/user', 3 );
if ( $checkRateLimitOnEmail instanceof Response ) {
$this->response = $checkRateLimitOnEmail;

return;
}

$signup = new SignupModel( $user );
// rate limit on IP
$checkRateLimitOnIp = $this->checkRateLimitResponse( $this->response, $userIp, '/api/app/user', 3 );
if ( $checkRateLimitOnIp instanceof Response ) {
$this->response = $checkRateLimitOnIp;

//email
return;
}

$signup = new SignupModel( $user );
$this->incrementRateLimitCounter( $userIp, '/api/app/user' );

// email
if ( $signup->valid() ) {
$signup->process();
$this->response->code( 200 );
Expand Down
Loading

0 comments on commit 716ccdb

Please sign in to comment.