Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 2 additions & 5 deletions config.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
- name: service-aletheia
conf:
port: 3000
cors: '*'
cors: "*"
debug: true
websocketUrl: wss://testws.aletheiafact.org
baseUrl: https://test.aletheiafact.org
Expand All @@ -14,8 +14,6 @@ services:
connection_uri: MONGODB_URI
atlas: true
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
throttle:
Expand All @@ -25,7 +23,7 @@ services:
ory:
url: ORY_SDK_URL
admin_url: ORY_SDK_URL
admin_endpoint: api/kratos/admin
admin_endpoint: api/kratos/admin
access_token: ORY_ACCESS_TOKEN
schema_id: ALETHEIA_SCHEMA_ID
feature_flag:
Expand All @@ -46,4 +44,3 @@ services:
api_token: ZENVIA_API_TOKEN
agencia:
access_token: AGENCIA_ACCESS_TOKEN

2 changes: 0 additions & 2 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ services:
connection_uri: mongodb://localhost/Aletheia
type: mongodb
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
throttle:
Expand Down
6 changes: 2 additions & 4 deletions config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
- name: service-aletheia
conf:
port: 3000
cors: '*'
cors: "*"
websocketUrl: wss://ws.aletheiafact.org
baseUrl: "https://aletheiafact.org"
automatedFactCheckingAPIUrl: AGENTS_API_URL
Expand All @@ -12,8 +12,6 @@ services:
atlas: true
connection_uri: MONGODB_URI
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
throttle:
Expand All @@ -23,7 +21,7 @@ services:
ory:
url: ORY_SDK_URL
admin_url: ORY_SDK_URL
admin_endpoint: admin
admin_endpoint: admin
access_token: ORY_ACCESS_TOKEN
schema_id: ALETHEIA_SCHEMA_ID
feature_flag:
Expand Down
8 changes: 3 additions & 5 deletions config.seed.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ services:
conf:
app_affiliation: aletheia
web_url: https://test.aletheiafact.org
smtp_host: {env(SMTP_CLIENT_HOST)}
smtp_port: {env(SMTP_CLIENT_PORT)}
smtp_host: { env(SMTP_CLIENT_HOST) }
smtp_port: { env(SMTP_CLIENT_PORT) }
smtp_secure: true
smtp_email_user: {env(SMTP_EMAIL_USER)}
smtp_email_user: { env(SMTP_EMAIL_USER) }
db:
connection_uri: MONGODB_URI
type: mongodb
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
users:
Expand Down
22 changes: 9 additions & 13 deletions config.seed.test.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ services:
conf:
disable_smtp: true
db:
connection_uri: {env(CI_MONGODB_URI)}
connection_uri: { env(CI_MONGODB_URI) }
type: mongodb
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
users:
- name: Test User
email: test-cypress@aletheiafact.org
password: {env(CI_ORY_USER_PASSWORD)}
password: { env(CI_ORY_USER_PASSWORD) }
sendAuthDetails: false
isTestUser: true
# If running locally and the seed fails,
# If running locally and the seed fails,
# check the user's oryId at the link below. http://localhost:4434/admin/identities
# oryId: {env(CI_ORY_USERID)}
role: {
main: super-admin
}
role: { main: super-admin }
throttle:
ttl: 60
limit: 1000
Expand All @@ -34,11 +30,11 @@ services:
# access_token: {env(ORY_ACCESS_TOKEN)}
# schema_id: {env(ALETHEIA_SCHEMA_ID)}
feature_flag:
url: {env(GITLAB_FEATURE_FLAG_URL)}
url: { env(GITLAB_FEATURE_FLAG_URL) }
appName: Staging
instanceId: {env(GITLAB_FEATURE_FLAG_INSTANCE_ID)}
instanceId: { env(GITLAB_FEATURE_FLAG_INSTANCE_ID) }
openai:
api_key: {env(OPENAI_API_KEY)}
api_key: { env(OPENAI_API_KEY) }
zenvia:
api_url: {env(ZENVIA_API_URL)}
api_token: {env(ZENVIA_API_TOKEN)}
api_url: { env(ZENVIA_API_URL) }
api_token: { env(ZENVIA_API_TOKEN) }
28 changes: 13 additions & 15 deletions config.test.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ services:
- name: ci-aletheia-server
conf:
port: 3000
cors: '*'
cors: "*"
debug: true
websocketUrl: ws://localhost:5001
recaptcha_secret: {env(TEST_RECAPTCHA_SECRET)}
recaptcha_sitekey: {env(TEST_RECAPTCHA_SITEKEY)}
recaptcha_secret: { env(TEST_RECAPTCHA_SECRET) }
recaptcha_sitekey: { env(TEST_RECAPTCHA_SITEKEY) }
db:
connection_uri: {env(CI_MONGODB_URI)}
connection_uri: { env(CI_MONGODB_URI) }
type: mongodb
options:
useUnifiedTopology: true
useNewUrlParser: true
retryWrites: true
w: majority
throttle:
Expand All @@ -27,17 +25,17 @@ services:
# access_token: {env(ORY_ACCESS_TOKEN)}
# schema_id: {env(ALETHEIA_SCHEMA_ID)}
feature_flag:
url: {env(GITLAB_FEATURE_FLAG_URL)}
url: { env(GITLAB_FEATURE_FLAG_URL) }
appName: Staging
instanceId: {env(GITLAB_FEATURE_FLAG_INSTANCE_ID)}
instanceId: { env(GITLAB_FEATURE_FLAG_INSTANCE_ID) }
aws:
bucket: {env(AWS_SDK_BUCKET)}
accessKeyId: {env(AWS_ACCESS_KEY_ID)}
secretAccessKey: {env(AWS_SECRET_ACCESS_KEY)}
bucket: { env(AWS_SDK_BUCKET) }
accessKeyId: { env(AWS_ACCESS_KEY_ID) }
secretAccessKey: { env(AWS_SECRET_ACCESS_KEY) }
openai:
api_key: {env(OPENAI_API_KEY)}
api_key: { env(OPENAI_API_KEY) }
zenvia:
api_url: {env(ZENVIA_API_URL)}
api_token: {env(ZENVIA_API_TOKEN)}
api_url: { env(ZENVIA_API_URL) }
api_token: { env(ZENVIA_API_TOKEN) }
agencia:
access_token: {env(AGENCIA_ACCESS_TOKEN)}
access_token: { env(AGENCIA_ACCESS_TOKEN) }
2 changes: 0 additions & 2 deletions deployment/config/config-file/modules/database/mongodb.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ atlas = false
type = "mongodb"
connection_uri = read("env:MONGODB_URI")
options = new {
useUnifiedTopology = true
useNewUrlParser = true
retryWrites = true
w = "majority"
}
2 changes: 0 additions & 2 deletions migrate-mongo-config-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const config = {
databaseName: "MONGODB_NAME",

options: {
useNewUrlParser: true, // removes a deprecation warning when connecting
useUnifiedTopology: true, // removes a deprecating warning when connecting
// connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
// socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"moment": "^2.30.1",
"mongodb": "^6.8.0",
"mongodb-memory-server": "^10.0.0",
"mongoose": "^ 5.13.15",
"mongoose": "6.13.9",
"mongoose-softdelete-typescript": "^0.0.3",
"nestjs-unleash": "^2.2.3",
"newrelic": "^11.5.0",
Expand Down
25 changes: 10 additions & 15 deletions server/auth/name-space/name-space.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ViewService } from "../../view/view.service";
import { CreateNameSpaceDTO } from "./dto/create-namespace.dto";
import { UpdateNameSpaceDTO } from "./dto/update-name-space.dto";
import { AdminOnly } from "../decorators/auth.decorator";
import { Types } from "mongoose";
import { Types, UpdateWriteOpResult } from "mongoose";
import { Roles } from "../../auth/ability/ability.factory";
import { NotificationService } from "../../notifications/notifications.service";
import slugify from "slugify";
Expand All @@ -31,7 +31,7 @@ export class NameSpaceController {
private usersService: UsersService,
private viewService: ViewService,
private notificationService: NotificationService,
private configService: ConfigService,
private configService: ConfigService
) {}

@AdminOnly()
Expand Down Expand Up @@ -85,9 +85,7 @@ export class NameSpaceController {
@AdminOnly()
@ApiTags("name-space")
@Get("api/name-space")
async findAllOrFiltered(
@Query("userId") userId?: string,
) {
async findAllOrFiltered(@Query("userId") userId?: string) {
if (userId) {
return this.nameSpaceService.findByUser(userId);
}
Expand All @@ -103,21 +101,18 @@ export class NameSpaceController {
const users = await this.usersService.findAll({});
const parsedUrl = parse(req.url, true);

const query = Object.assign(
parsedUrl.query,
{
sitekey: this.configService.get<string>("recaptcha_sitekey"),
nameSpaces,
users
}
);
const query = Object.assign(parsedUrl.query, {
sitekey: this.configService.get<string>("recaptcha_sitekey"),
nameSpaces,
users,
});

await this.viewService.render(req, res, "/admin-namespaces", query);
}

private async updateNameSpaceUsers(users, newKey, oldKey = null) {
const promises = users.map(async (user) => {
const userId = Types.ObjectId(user._id);
const userId = new Types.ObjectId(user._id);
const existingUser = await this.usersService.getById(userId);

let updatedRoles = { ...existingUser.role };
Expand Down Expand Up @@ -163,7 +158,7 @@ export class NameSpaceController {

private async deleteUsersNameSpace(usersId, key) {
const updatePromises = usersId.map(async (userId) => {
const id = Types.ObjectId(userId);
const id = new Types.ObjectId(userId);
const user = await this.usersService.getById(id);
delete user.role[key];
return this.usersService.updateUser(user._id, { role: user.role });
Expand Down
7 changes: 5 additions & 2 deletions server/auth/name-space/name-space.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export class NameSpaceService {
return newNameSpace;
}

async update(id, newNameSpace: UpdateNameSpaceDTO) {
async update(
id,
newNameSpace: UpdateNameSpaceDTO
): Promise<NameSpaceDocument> {
const isNameSpaceTopic = await this.notificationService.getTopic(
newNameSpace._id
);
Expand All @@ -50,7 +53,7 @@ export class NameSpaceService {
isNameSpaceTopic
);

return await this.NameSpaceModel.updateOne(
return await this.NameSpaceModel.findByIdAndUpdate(
{ _id: newNameSpace._id },
newNameSpace
);
Expand Down
19 changes: 6 additions & 13 deletions server/badge/badge.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Body,
Controller,
Get,
Post,
Put,
Req,
Res,
} from "@nestjs/common";
import { Body, Controller, Get, Post, Put, Req, Res } from "@nestjs/common";
import type { Request, Response } from "express";
import { ImageService } from "../claim/types/image/image.service";
import { parse } from "url";
Expand All @@ -30,7 +22,7 @@ export class BadgeController {
private imageService: ImageService,
private usersService: UsersService,
private util: UtilService,
private configService: ConfigService,
private configService: ConfigService
) {}

@AdminOnly()
Expand Down Expand Up @@ -70,14 +62,14 @@ export class BadgeController {

if (!rest.image._id) {
const image = await this.imageService.create(rest.image);
rest.image = Types.ObjectId(image._id);
rest.image = new Types.ObjectId(image._id);
}

const updatedBadge = await this.badgeService.update(rest);
updatedBadge.image = rest.image;

const usersWithBadge = await this.usersService.findAll({
badges: Types.ObjectId(updatedBadge._id),
badges: new Types.ObjectId(updatedBadge._id),
});

// Remove badge from users that no longer have it
Expand Down Expand Up @@ -116,7 +108,8 @@ export class BadgeController {
if (
!user.badges?.some(
(userBadge) =>
userBadge._id !== Types.ObjectId(updatedBadge._id)
userBadge._id !==
new Types.ObjectId(updatedBadge._id)
)
) {
this.usersService.updateUser(user._id, {
Expand Down
4 changes: 2 additions & 2 deletions server/badge/badge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class BadgeService {
async create(badge) {
const newBadge = new this.BadgeModel({
...badge,
image: Types.ObjectId(badge.image._id),
image: new Types.ObjectId(badge.image._id),
});
return await newBadge.save();
}
Expand All @@ -22,7 +22,7 @@ export class BadgeService {
const { image, ...updatedFields } = badge;
const controlledBadge = {
...updatedFields,
image: Types.ObjectId(badge.image._id),
image: new Types.ObjectId(badge.image._id),
};
const updatedBadge = this.BadgeModel.findByIdAndUpdate(
badge._id,
Expand Down
2 changes: 1 addition & 1 deletion server/chat-bot-state/chat-bot-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ChatBotStateService {
return await this.ChatBotStateModel.findByIdAndUpdate(
id,
{ machine: snapshot },
{ new: true, useFindAndModify: false }
{ new: true }
).exec();
}

Expand Down
Loading
Loading