Skip to content

Commit

Permalink
Merge pull request #965 from AletheiaFact/stage
Browse files Browse the repository at this point in the history
Production Release: v2.0.0
  • Loading branch information
thesocialdev authored Aug 28, 2023
2 parents 5dde3d7 + 4a22a32 commit ea2f342
Show file tree
Hide file tree
Showing 84 changed files with 4,896 additions and 2,786 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/sweep-bugfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Bugfix
title: 'Sweep: '
description: Write something like "We notice ... behavior when ... happens instead of ...""
labels: sweep
body:
- type: textarea
id: description
attributes:
label: Details
description: More details about the bug
placeholder: The bug might be in ... file
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/sweep-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Feature Request
title: 'Sweep: '
description: Write something like "Write an api endpoint that does "..." in the "..." file"
labels: sweep
body:
- type: textarea
id: description
attributes:
label: Details
description: More details for Sweep
placeholder: The new endpoint should use the ... class from ... file because it contains ... logic
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/sweep-refactor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Refactor
title: 'Sweep: '
description: Write something like "Modify the ... api endpoint to use ... version and ... framework"
labels: sweep
body:
- type: textarea
id: description
attributes:
label: Details
description: More details for Sweep
placeholder: We are migrating this function to ... version because ...
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

strategy:
matrix:
node-version: [14.19.0]
node-version: [16.19.0]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.19.0
16.19.0
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.19.0-alpine AS package
FROM node:16.19.0-alpine AS package

ARG NEXT_PUBLIC_UMAMI_SITE_ID
ARG NEXT_PUBLIC_RECAPTCHA_SITEKEY
Expand Down Expand Up @@ -31,7 +31,7 @@ RUN NEXT_PUBLIC_UMAMI_SITE_ID=$NEXT_PUBLIC_UMAMI_SITE_ID \
NEXT_PUBLIC_RECAPTCHA_SITEKEY=$NEXT_PUBLIC_RECAPTCHA_SITEKEY \
yarn build

FROM node:14.19.0-alpine
FROM node:16.19.0-alpine

LABEL maintainer="Giovanni Rossini <[email protected]>"

Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@
"@nestjs/mongoose": "^8.0.0",
"@nestjs/platform-express": "9.2.0",
"@nestjs/schedule": "^2.1.0",
"@nestjs/swagger": "^7.1.4",
"@nestjs/throttler": "^2.0.0",
"@ory/cli": "^0.1.24",
"@ory/client": "0.0.1-alpha.153",
"@ory/integrations": "^0.2.5",
"@remirror/extension-yjs": "^3.0.14",
"@remirror/pm": "^2.0.0",
"@remirror/react": "^2.0.12",
"@remirror/react-editors": "^1.0.12",
Expand All @@ -109,6 +111,7 @@
"express-session": "^1.17.2",
"handlebars": "^4.7.7",
"helmet": "^6.0.0",
"html-to-text": "^9.0.5",
"i18next": "^21.6.10",
"jotai": "^1.9.2",
"js-cookie": "^3.0.1",
Expand Down Expand Up @@ -143,7 +146,12 @@
"sitemap": "5",
"slugify": "^1.6.1",
"styled-components": "^5.3.0",
"xstate": "^4.32.1"
"ws": "^8.13.0",
"xstate": "^4.32.1",
"y-protocols": "^1.0.5",
"y-webrtc": "^10.2.5",
"y-websocket": "^1.5.0",
"yjs": "^13.5.23"
},
"devDependencies": {
"@babel/core": "^7.15.0",
Expand Down Expand Up @@ -190,7 +198,7 @@
"husky": "^8.0.1",
"jest": "^27.4.7",
"lint-staged": "^13.0.3",
"mongodb-memory-server": "^8.6.0",
"mongodb-memory-server": "^8.13.0",
"nodemon": "^2.0.12",
"prettier": "2.3.2",
"react-i18next": "^11.16.7",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/en/sourceForm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"addNewSourceButton": "Add another link",
"errorMessageValidURL": "Please insert a valid URL",
"errorMessageNoURL": "Insert at least one source on the summary",
"label": "Provide at least one link to a reliable source",
"placeholder": "Paste URL",
"extra": "We accept news website URLs, link to academic papers, online official documents, and social media posts created by the personality themselves."
"extra": "We accept news website URLs, link to academic papers, online official documents, and social media posts created by the personality themselves.",
"sourceModalHeader": "Add new source"
}
6 changes: 6 additions & 0 deletions public/locales/en/warningModal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Are you sure you want {{warning}}?",
"gobackWarning": "to go back",
"okButton": "Done",
"cancelButton": "Cancel"
}
4 changes: 3 additions & 1 deletion public/locales/pt/sourceForm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"addNewSourceButton": "Insira outro link",
"errorMessageValidURL": "Por favor insira um link válido",
"errorMessageNoURL": "Insira ao menos um link no sumário",
"label": "Forneça ao menos um link de uma fonte confiável",
"placeholder": "Cole uma URL",
"extra": "Nós aceitamos links de website de notícias, links para artigos acadêmicos, documentos oficiais digitalizados e disponíveis online e postagens de mídias sociais criadas pelas próprias personalidades."
"extra": "Nós aceitamos links de website de notícias, links para artigos acadêmicos, documentos oficiais digitalizados e disponíveis online e postagens de mídias sociais criadas pelas próprias personalidades.",
"sourceModalHeader": "Adicione uma fonte"
}
6 changes: 6 additions & 0 deletions public/locales/pt/warningModal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Tem certeza que deseja {{warning}}?",
"gobackWarning": "voltar",
"okButton": "Pronto",
"cancelButton": "Cancelar"
}
5 changes: 5 additions & 0 deletions server/badge/badge.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CreateBadgeDTO } from "./dto/create-badge.dto";
import { UpdateBadgeDTO } from "./dto/update-badge.dto";
import { UsersService } from "../users/users.service";
import { Types } from "mongoose";
import { ApiTags } from "@nestjs/swagger";

@Controller()
export class BadgeController {
Expand All @@ -19,6 +20,7 @@ export class BadgeController {
private usersService: UsersService
) {}

@ApiTags("badge")
@Post("api/badge")
public async createBadge(@Body() badge: CreateBadgeDTO) {
const { users, ...rest } = badge;
Expand All @@ -43,6 +45,7 @@ export class BadgeController {
return createdBadge;
}

@ApiTags("badge")
@Put("api/badge/:id")
public async updateBadge(@Body() badge: UpdateBadgeDTO) {
const { users, ...rest } = badge;
Expand Down Expand Up @@ -99,11 +102,13 @@ export class BadgeController {
return updatedBadge;
}

@ApiTags("badge")
@Get("api/badge")
public async listBadges() {
return this.badgeService.listAll();
}

@ApiTags("admin")
@Get("admin/badges")
public async adminBadges(@Req() req: Request, @Res() res: Response) {
const badges = await this.badgeService.listAll();
Expand Down
6 changes: 6 additions & 0 deletions server/badge/dto/create-badge.dto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import {
IsArray,
IsDateString,
Expand All @@ -10,21 +11,26 @@ import {
export class CreateBadgeDTO {
@IsString()
@IsNotEmpty()
@ApiProperty()
name: string;

@IsString()
@IsNotEmpty()
@ApiProperty()
description: string;

@IsObject()
@IsNotEmpty()
@ApiProperty()
image: any;

@IsDateString()
@IsNotEmpty()
@ApiProperty()
created_at: string;

@IsArray()
@IsOptional()
@ApiProperty()
users: { badges: any[]; name: string; _id: string }[];
}
6 changes: 6 additions & 0 deletions server/badge/dto/update-badge.dto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import {
IsArray,
IsNotEmpty,
Expand All @@ -9,21 +10,26 @@ import {
export class UpdateBadgeDTO {
@IsString()
@IsNotEmpty()
@ApiProperty()
_id: string;

@IsString()
@IsNotEmpty()
@ApiProperty()
name: string;

@IsString()
@IsNotEmpty()
@ApiProperty()
description: string;

@IsObject()
@IsNotEmpty()
@ApiProperty()
image: any;

@IsArray()
@IsOptional()
@ApiProperty()
users: { badges: any[]; name: string; _id: string }[];
}
23 changes: 22 additions & 1 deletion server/claim-review-task/claim-review-task.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Req,
Res,
Header,
Optional,
} from "@nestjs/common";
import { ClaimReviewTaskService } from "./claim-review-task.service";
import { CreateClaimReviewTaskDTO } from "./dto/create-claim-review-task.dto";
Expand All @@ -20,16 +21,20 @@ import { ViewService } from "../view/view.service";
import { GetTasksDTO } from "./dto/get-tasks.dto";
import { getQueryMatchForMachineValue } from "./mongo-utils";
import { ConfigService } from "@nestjs/config";
import { UnleashService } from "nestjs-unleash";
import { ApiTags } from "@nestjs/swagger";

@Controller()
export class ClaimReviewController {
constructor(
private claimReviewTaskService: ClaimReviewTaskService,
private captchaService: CaptchaService,
private viewService: ViewService,
private configService: ConfigService
private configService: ConfigService,
@Optional() private readonly unleash: UnleashService
) {}

@ApiTags("claim-review-task")
@Get("api/claimreviewtask")
@Header("Cache-Control", "no-cache")
public async getByMachineValue(@Query() getTasksDTO: GetTasksDTO) {
Expand Down Expand Up @@ -64,12 +69,14 @@ export class ClaimReviewController {
});
}

@ApiTags("claim-review-task")
@Get("api/claimreviewtask/:id")
@Header("Cache-Control", "no-cache")
async getById(@Param("id") id: string) {
return this.claimReviewTaskService.getById(id);
}

@ApiTags("claim-review-task")
@Post("api/claimreviewtask")
@Header("Cache-Control", "no-cache")
async create(@Body() createClaimReviewTask: CreateClaimReviewTaskDTO) {
Expand All @@ -82,6 +89,7 @@ export class ClaimReviewController {
return this.claimReviewTaskService.create(createClaimReviewTask);
}

@ApiTags("claim-review-task")
@Put("api/claimreviewtask/:data_hash")
@Header("Cache-Control", "no-cache")
async autoSaveDraft(
Expand All @@ -103,6 +111,7 @@ export class ClaimReviewController {
}

// TODO: remove hash from the url
@ApiTags("claim-review-task")
@Get("api/claimreviewtask/hash/:data_hash")
@Header("Cache-Control", "no-cache")
async getByDataHash(@Param("data_hash") data_hash: string) {
Expand All @@ -111,18 +120,30 @@ export class ClaimReviewController {
);
}

@ApiTags("pages")
@Get("kanban")
@Header("Cache-Control", "no-cache")
public async personalityList(@Req() req: Request, @Res() res: Response) {
const parsedUrl = parse(req.url, true);

const enableCollaborativeEditor = this.isEnableCollaborativeEditor();

await this.viewService.getNextServer().render(
req,
res,
"/kanban-page",
Object.assign(parsedUrl.query, {
sitekey: this.configService.get<string>("recaptcha_sitekey"),
enableCollaborativeEditor,
})
);
}

private isEnableCollaborativeEditor() {
const config = this.configService.get<string>("feature_flag");

return config
? this.unleash.isEnabled("enable_collaborative_editor")
: false;
}
}
2 changes: 1 addition & 1 deletion server/claim-review-task/claim-review-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ClaimReviewTaskService {
async listAll(page, pageSize, order, value, filterUser) {
const pipeline = this._buildPipeline(value, filterUser);
pipeline.push(
{ $sort: { _id: order === "asc" ? 1 : 0 } },
{ $sort: { _id: order === "asc" ? 1 : -1 } },
{ $skip: page * pageSize },
{ $limit: pageSize }
);
Expand Down
6 changes: 5 additions & 1 deletion server/claim-review-task/dto/create-claim-review-task.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ClassificationEnum } from "../../claim-review/dto/create-claim-review.d
import { Claim } from "../../claim/schemas/claim.schema";
import { Personality } from "../../personality/schemas/personality.schema";
import { User } from "../../users/schemas/user.schema";
import { ApiProperty } from "@nestjs/swagger";

export type ReviewTaskMachineContext = {
reviewData: {
Expand All @@ -12,7 +13,7 @@ export type ReviewTaskMachineContext = {
questions?: string[];
report?: string;
verification?: string;
sources?: string[];
sources?: string[] | object[];
classification?: ClassificationEnum;
data_hash: string;
reviewerId?: any;
Expand All @@ -39,13 +40,16 @@ export type Machine = {
export class CreateClaimReviewTaskDTO {
@IsNotEmpty()
@IsObject()
@ApiProperty()
machine: Machine;

@IsNotEmpty()
@IsString()
@ApiProperty()
data_hash: string;

@IsNotEmpty()
@IsString()
@ApiProperty()
recaptcha: string;
}
Loading

0 comments on commit ea2f342

Please sign in to comment.