Skip to content

Commit 10d0f93

Browse files
authored
Merge pull request #35 from xeptagondev/meedan_label_issue
Meedan label issue
2 parents 2411526 + 402a264 commit 10d0f93

File tree

7 files changed

+105
-31
lines changed

7 files changed

+105
-31
lines changed

apps/publisher/src/wp-publisher/wp-publisher-helper.service.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { TasksLabels } from "@iverify/common/src";
1+
import { getLabel, MeedanLabels,} from "@iverify/common/src";
22
import { Injectable } from "@nestjs/common";
33
import { CommentStatus, CreatePostDto, PostFields, PostFormat, PostStatus } from "libs/wp-client/src/lib/interfaces/create-post.dto";
44
import { SharedHelper } from "../shared/helper";
55
var showdown = require('showdown')
66

77
@Injectable()
88
export class WpPublisherHelper{
9-
lang = process.env.language;
9+
lang = process.env.language + `-` + process.env.COUNTRY_CODE;
1010

1111
constructor(private sharedHelper: SharedHelper){}
1212

@@ -36,22 +36,22 @@ export class WpPublisherHelper{
3636
const title = meedanReport.title;
3737
const subtitle = meedanReport.description;
3838

39-
const violation_type = this.sharedHelper.extractTask(report, TasksLabels[this.lang].violation_type);
39+
const violation_type = this.sharedHelper.extractTask(report, getLabel(this.lang, MeedanLabels.VIOLATION_TYPE));
4040
// const toxicField = this.sharedHelper.extractTask(report, TasksLabels[this.lang].toxic);
4141
// const toxic = !!toxicField ? 1 : 0;
42-
const toxic = (violation_type === TasksLabels[this.lang].violation_hate_speech) ? 1 : 0;
42+
const toxic = (violation_type === getLabel(this.lang, MeedanLabels.VIOLATION_HATE_SPEECH)) ? 1 : 0;
4343
const factchecking_status = this.extractFactcheckingStatus(report);
4444
const claim = this.sharedHelper.extractTitle(report);
4545
// this.sharedHelper.extractTask(report, TasksLabels[this.lang].claim);
46-
let rating_justification = this.sharedHelper.extractTask(report, TasksLabels[this.lang].rating_justification);
46+
let rating_justification = this.sharedHelper.extractTask(report, getLabel(this.lang, MeedanLabels.RATING_JUSTIFICATION));
4747
rating_justification = this.formatMarkupText(rating_justification);
48-
const evidence = this.sharedHelper.extractTask(report, TasksLabels[this.lang].evidences_and_references);
48+
const evidence = this.sharedHelper.extractTask(report,getLabel(this.lang, MeedanLabels.EVIDENCES_AND_REFERENCES));
4949
const evidence_and_references = this.formatEvidence(evidence);
5050
const _webdados_fb_open_graph_specific_image = visualCard;
51-
const category = this.sharedHelper.extractTask(report, TasksLabels[this.lang].category_checked);
51+
const category = this.sharedHelper.extractTask(report, getLabel(this.lang, MeedanLabels.CATEGORY_CHECKED));
5252
const fields: PostFields = {check_id, factchecking_status, claim, rating_justification, evidence_and_references, subtitle, toxic,category};
5353
console.log('visual card url: ', _webdados_fb_open_graph_specific_image)
54-
const email_address = this.sharedHelper.extractTask(report, TasksLabels[this.lang].email_address);
54+
const email_address = this.sharedHelper.extractTask(report, getLabel(this.lang, MeedanLabels.EMAIL_ADDRESS));
5555
const post: CreatePostDto = {
5656
format,
5757
author,

apps/triage/src/app/app.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HttpException, HttpService, Injectable, Logger } from '@nestjs/common';
1+
import { HttpException, Injectable, Logger } from '@nestjs/common';
22
import { CrowdtangleClientService } from 'libs/crowdtangle-client/src/lib/crowdtangle-client.service';
33
import { UnitedwaveClientService } from 'libs/unitedwave-client/src/lib/unitedwave-client.service';
44
import { MeedanCheckClientService, ToxicityScores } from '@iverify/meedan-check-client';

libs/common/src/lib/common.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
import { TasksLabels } from "./tasks-labels";
2+
13
export function common(): string {
24
return 'common';
35
}
6+
7+
8+
export function getLabel(lang, key) {
9+
// Check the country-specific language first
10+
if (TasksLabels[lang] && TasksLabels[lang][key]) {
11+
return TasksLabels[lang][key];
12+
}
13+
// Fallback to base language (e.g., 'en' from 'en-malawi')
14+
const baseLang = lang.split('-')[0]; // Extract base language code
15+
console.log('baselang', baseLang,lang)
16+
if (TasksLabels[baseLang] && TasksLabels[baseLang][key]) {
17+
return TasksLabels[baseLang][key];
18+
}
19+
// If key is not found in either, return null or a default value
20+
return null;
21+
}

libs/common/src/lib/tasks-labels.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,61 @@ export const TasksLabels = {
178178
message:'message',
179179
original_reported_date: 'original_reported_date',
180180
meedan_category:'category'
181-
},
181+
182+
},
183+
"en-mw": {
184+
rating_justification: 'Verdict and Verification Process',
185+
evidences_and_references: 'Evidence and References',
186+
violation_type: 'Type of Violation',
187+
meedan_category:'Category',
188+
email_address: 'Email Address',
189+
upload_file: 'Upload Files',
190+
}
191+
}
192+
193+
194+
export enum MeedanLabels {
195+
CLAIM = "claim",
196+
RATING_JUSTIFICATION = "rating_justification",
197+
EVIDENCES_AND_REFERENCES = "evidences_and_references",
198+
CARD_TITLE = "card_title",
199+
TOXIC = "toxic",
200+
THREAT_LEVEL = "threat_level",
201+
VIOLATION_TYPE = "violation_type",
202+
DISINFO_TYPE = "disinfo_type",
203+
HATE_SPEECH_TYPE = "hate_speech_type",
204+
TOXIC_SCORE = "toxic_score",
205+
OBSCENE_SCORE = "obscene_score",
206+
IDENTITY_SCORE = "identity_score",
207+
THREAT_SCORE = "threat_score",
208+
SEXUALLY_EXPLICIT_SCORE = "sexually_explicit_score",
209+
D_TOXIC_SCORE = "d_toxic_score",
210+
D_SEVERE_TOXIC_SCORE = "d_severe_toxic_score",
211+
D_OBSCENE_SCORE = "d_obscene_score",
212+
D_IDENTITY_SCORE = "d_identity_score",
213+
D_INSULT_SCORE = "d_insult_score",
214+
D_THREAT_SCORE = "d_threat_score",
215+
D_SEXUALLY_EXPLICIT_SCORE = "d_sexually_explicit_score",
216+
VIOLATION_DISINFO = "violation_disinfo",
217+
VIOLATION_MISINFO = "violation_misinfo",
218+
VIOLATION_HATE_SPEECH = "violation_hate_speech",
219+
VIOLATION_THREAT = "violation_threat",
220+
VIOLATION_VIOLENCE = "violation_violence",
221+
VIOLATION_NO_THREAT = "violation_no_threat",
222+
STATUS_UNSTARTED = "status_unstarted",
223+
STATUS_IN_PROGRESS = "status_in_progress",
224+
STATUS_FALSE = "status_false",
225+
STATUS_TRUE = "status_true",
226+
STATUS_MISLEADING = "status_misleading",
227+
STATUS_OUT_OF_SCOPE = "status_out_of_scope",
228+
STATUS_PARTLY_FALSE = "status_partly_false",
229+
STATUS_INCONCLUSIVE = "status_inconclusive",
230+
STATUS_PRE_CHECKED = "status_pre_checked",
231+
CATEGORY_CHECKED = "category_checked",
232+
EMAIL_ADDRESS = "email_address",
233+
UPLOAD_FILE = "upload_file",
234+
AUDIO_URL = "audio_url",
235+
MESSAGE = "message",
236+
ORIGINAL_REPORTED_DATE = "original_reported_date",
237+
MEEDAN_CATEGORY = "meedan_category",
182238
}

libs/meedan-check-client/src/lib/check-stats.service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TasksLabels } from "@iverify/common/src";
22
import { HttpException, HttpService, Injectable, Logger } from "@nestjs/common";
33
import { combineLatest, from, Observable } from "rxjs";
4-
import { catchError, concatMap, filter, first, map, reduce, retry, take, tap } from "rxjs/operators";
4+
import { catchError, concatMap, filter, map, reduce, retry} from "rxjs/operators";
55
import { CheckClientConfig } from "./config";
66
import { CheckClientHelperService } from "./helper.service";
77
// import { StatusesMap, TasksLabels } from "@iverify/iverify-common";
@@ -12,12 +12,12 @@ export class CheckStatsService{
1212
lang = process.env.language;
1313

1414
constructor(
15-
private http: HttpService,
15+
private http: HttpService,
1616
private config: CheckClientConfig,
1717
private helper: CheckClientHelperService
1818
){}
1919

20-
20+
2121

2222
getTicketsByAgent(statuses: string[]): Observable<any>{
2323
const teamSlug = this.config.checkApiTeam;
@@ -29,7 +29,7 @@ export class CheckStatsService{
2929
this.logger.error(`Error getting tickets by agents: `, err.message)
3030
throw new HttpException(err.message, 500);
3131
})
32-
)
32+
)
3333
}
3434

3535
getByAgentAllStatuses(agent: any, statuses: string[]){
@@ -57,7 +57,7 @@ export class CheckStatsService{
5757
this.logger.error(`Error getting tickets for agentId ${agentId} and status ${status}: `, err.message)
5858
throw new HttpException(err.message, 500);
5959
})
60-
);
60+
);
6161
}
6262

6363
getAllAgents(teamSlug: string){
@@ -71,7 +71,7 @@ export class CheckStatsService{
7171
this.logger.error('Error getting all agents: ', err.message)
7272
throw new HttpException(err.message, 500);
7373
})
74-
);
74+
);
7575
}
7676

7777
getTicketsByInputProjects(){
@@ -116,7 +116,7 @@ export class CheckStatsService{
116116
this.logger.error(`Error getting tickets for projectId ${projectId}: `, err.message)
117117
throw new HttpException(err.message, 500);
118118
})
119-
);
119+
);
120120
}
121121

122122
getAllProjects(teamSlug: string){
@@ -130,7 +130,7 @@ export class CheckStatsService{
130130
this.logger.error('Error getting all agents: ', err.message)
131131
throw new HttpException(err.message, 500);
132132
})
133-
);
133+
);
134134
}
135135

136136
getTicketsByTags(): Observable<any>{
@@ -308,4 +308,4 @@ export class CheckStatsService{
308308
})
309309
);
310310
}
311-
}
311+
}

libs/meedan-check-client/src/lib/helper.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Injectable } from '@nestjs/common';
2-
import { throwIfEmpty } from 'rxjs/operators';
2+
// import { throwIfEmpty } from 'rxjs/operators';
33
import { ToxicityScores } from './interfaces/toxicity-scores';
4-
import { TasksLabels } from '@iverify/common/src';
4+
import { getLabel, MeedanLabels} from '@iverify/common/src';
55

66
@Injectable()
77
export class CheckClientHelperService {
8-
lang = process.env.language;
8+
lang = process.env.language + `-` + process.env.COUNTRY_CODE;
99
buildGetReportQuery(id: string) {
1010
return `query {
1111
project_media(ids: "${id}"){
@@ -81,9 +81,9 @@ export class CheckClientHelperService {
8181

8282
buildCreateItemFromRadioMessage(url: string, name, content, created_date, tag = 'Radio') {
8383
const tasksResponsesObj = {
84-
[TasksLabels[this.lang].audio_url]: url,
85-
[TasksLabels[this.lang].message]: content,
86-
[TasksLabels[this.lang].original_reported_date]: created_date,
84+
[getLabel(this.lang, MeedanLabels.AUDIO_URL)]: url,
85+
[getLabel(this.lang, MeedanLabels.MESSAGE)]: content,
86+
[getLabel(this.lang, MeedanLabels.ORIGINAL_REPORTED_DATE)]: created_date,
8787
};
8888
let setTasksResponses = JSON.stringify(tasksResponsesObj);
8989
setTasksResponses = setTasksResponses.replace(/\\/g, '\\\\').replace(/"/g, '\\"');

libs/meedan-check-client/src/lib/meedan-check-client.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { HttpException, HttpService, Injectable, Logger } from '@nestjs/common';
2-
import { forkJoin, from, iif, Observable, of } from 'rxjs';
2+
import { forkJoin, from, Observable, of } from 'rxjs';
33
import { catchError, map, retry, switchMap, tap } from 'rxjs/operators';
44
import { CheckClientConfig } from './config';
55
import { CheckClientHelperService } from './helper.service';
66
import { ToxicityScores } from './interfaces/toxicity-scores';
77
import { S3Service } from 'libs/s3/src/lib/s3.service';
88
import { v4 as uuidv4 } from 'uuid';
9-
import { TasksLabels } from '@iverify/common/src';
9+
import { getLabel, MeedanLabels} from '@iverify/common/src';
1010
@Injectable()
1111
export class MeedanCheckClientService {
1212
private readonly logger = new Logger('MeedanCheckClient');
13-
lang = process.env.language;
13+
lang = process.env.language + `-` + process.env.COUNTRY_CODE;
1414
constructor(
1515
private http: HttpService,
1616
private config: CheckClientConfig,
@@ -204,7 +204,7 @@ export class MeedanCheckClientService {
204204

205205
if (files) {
206206
const bucketName:string = process.env.AWS_BUCKET_NAME ?? 'iverify-prod-cd-web'
207-
const id = this.getAnnotationId(annotationList, `${TasksLabels[this.lang].upload_file}`);
207+
const id = this.getAnnotationId(annotationList, `${getLabel(this.lang, MeedanLabels.UPLOAD_FILE)}`);
208208
let url_format = '';
209209
for (let count = 1; count <= files.length; count++) {
210210
// Upload the current file to the bucket and get the file URL
@@ -236,7 +236,7 @@ export class MeedanCheckClientService {
236236
): Observable<any> {
237237
const emailAnnotationId = this.getAnnotationId(
238238
annotationList,
239-
TasksLabels[this.lang].email_address
239+
getLabel(this.lang, MeedanLabels.EMAIL_ADDRESS)
240240
);
241241
const combinedQuery = this.helper.buildAnnotationItemsCombinedFromWpMutation(
242242
emailAnnotationId,
@@ -255,7 +255,7 @@ export class MeedanCheckClientService {
255255
const headers = this.config.headers;
256256
const categoryId = this.getAnnotationId(
257257
annotationList,
258-
TasksLabels[this.lang].meedan_category
258+
getLabel(this.lang, MeedanLabels.MEEDAN_CATEGORY)
259259
);
260260
console.log('UpdateRadioCategory',categoryId,category)
261261
const combinedQuery = this.helper.buildAnnotationItemsCombinedFromWpMutation(

0 commit comments

Comments
 (0)