Merge Dev in Staging
This commit is contained in:
commit
0409eed42d
@ -1,5 +1,5 @@
|
||||
# Install dependencies only when needed
|
||||
FROM node:19-alpine AS deps
|
||||
FROM node:18-bullseye-slim AS deps
|
||||
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
|
||||
ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser
|
||||
@ -9,7 +9,7 @@ WORKDIR leCoffre
|
||||
RUN npm install -D prisma@4.11.0
|
||||
COPY package.json ./
|
||||
|
||||
RUN apk update && apk add openssh-client git chromium
|
||||
RUN apt update && apt install openssh-client git chromium
|
||||
|
||||
COPY id_rsa /root/.ssh/id_rsa
|
||||
RUN chmod 600 ~/.ssh/id_rsa
|
||||
|
@ -1,6 +1,5 @@
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import roleHandler from "@App/middlewares/RolesHandler";
|
||||
import NotificationBuilder from "@Common/notifications/NotificationBuilder";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import { Controller, Delete, Post } from "@ControllerPattern/index";
|
||||
import { EAppointmentStatus, Votes } from "@prisma/client";
|
||||
@ -17,7 +16,6 @@ export default class LiveVoteController extends ApiController {
|
||||
constructor(
|
||||
private liveVoteService: LiveVoteService,
|
||||
private usersService: UsersService,
|
||||
private notificationBuilder: NotificationBuilder,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@ -81,8 +79,6 @@ export default class LiveVoteController extends ApiController {
|
||||
//Hydrate ressource with prisma entity
|
||||
const vote = Vote.hydrate<Vote>(voteEntityCreated, { strategy: "excludeAll" });
|
||||
|
||||
await this.notificationBuilder.sendVoteNotification(vote);
|
||||
|
||||
//success
|
||||
this.httpCreated(response, vote);
|
||||
} catch (error) {
|
||||
|
@ -9,6 +9,11 @@ export default async function fileHandler(req: Request, response: Response, next
|
||||
const uid = req.path && req.path.split("/")[5];
|
||||
const document = req.body.document;
|
||||
|
||||
if (req.file?.mimetype !== "application/pdf" && req.file?.mimetype !== "image/png" && req.file?.mimetype !== "image/jpeg") {
|
||||
response.status(HttpCodes.BAD_REQUEST).send("File type not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (uid) {
|
||||
const fileService = Container.get(FilesService);
|
||||
const file = await fileService.getByUidWithDocument(uid);
|
||||
|
@ -69,6 +69,8 @@ export default class NotificationBuilder {
|
||||
public async sendVoteNotification(vote: Vote) {
|
||||
if (vote.appointment.status !== "OPEN") return;
|
||||
const superAdminList = await this.usersService.get({ where: { role: { name: "super-admin" } } });
|
||||
const voterIndex = superAdminList.findIndex((user) => user.uid === vote.voter.uid);
|
||||
superAdminList.splice(voterIndex, 1);
|
||||
const userTargeted = await this.usersService.getByUid(vote.appointment.user.uid!, { contact: true });
|
||||
const userTargetedEntity = User.hydrate<User>(userTargeted!, { strategy: "excludeAll" });
|
||||
let message = "";
|
||||
@ -83,7 +85,7 @@ export default class NotificationBuilder {
|
||||
redirection_url: `${this.backendVariables.APP_HOST}/users/${vote.appointment.user.uid}`,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
user: superAdminList || [],
|
||||
user: superAdminList,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ export default class VotesRepository extends BaseRepository {
|
||||
}
|
||||
};
|
||||
|
||||
return this.model.create({...createArgs, include: {appointment: {include: {votes: true, user: true}}}});
|
||||
return this.model.create({...createArgs, include: {voter: true, appointment: {include: {votes: true, user: true}}}});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,6 @@ export default class AnchoringProofService extends BaseService {
|
||||
public async generate(data: AnchoringProofData): Promise<Buffer> {
|
||||
const browser = await puppeteer.launch({
|
||||
headless: "new",
|
||||
executablePath: process.env['PUPPETEER_EXECUTABLE_PATH'],
|
||||
args: ["--no-sandbox", "--disable-setuid-sandbox"],
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
|
@ -67,7 +67,7 @@ export default class LiveVoteService extends BaseService {
|
||||
return this.appointmentRepository.findOneByUid(uid, query);
|
||||
}
|
||||
|
||||
public async getAppointmentWithVotes(vote: Vote): Promise<(Appointments & {votes: Votes[], user: Users}) | null> {
|
||||
public async getAppointmentWithVotes(vote: Vote): Promise<(Appointments & { votes: Votes[]; user: Users }) | null> {
|
||||
if (vote.appointment.uid) {
|
||||
return this.appointmentRepository.findOneByUidWithVotes(vote.appointment.uid);
|
||||
}
|
||||
@ -88,7 +88,11 @@ export default class LiveVoteService extends BaseService {
|
||||
}
|
||||
|
||||
private async closeVote(appointment: Appointments, vote: Votes) {
|
||||
const apointmentFound = await this.appointmentRepository.findOneByStatusUserAndChoice(appointment.user_uid, EVote[appointment.choice as keyof typeof EVote], EAppointmentStatus.CLOSED);
|
||||
const apointmentFound = await this.appointmentRepository.findOneByStatusUserAndChoice(
|
||||
appointment.user_uid,
|
||||
EVote[appointment.choice as keyof typeof EVote],
|
||||
EAppointmentStatus.CLOSED,
|
||||
);
|
||||
if (apointmentFound) {
|
||||
await this.appointmentRepository.delete(apointmentFound.uid);
|
||||
}
|
||||
@ -137,7 +141,9 @@ export default class LiveVoteService extends BaseService {
|
||||
|
||||
const approvedChoice = await this.verifyVoterChoice(vote);
|
||||
if (!approvedChoice) return null;
|
||||
|
||||
return this.voteRepository.create(vote);
|
||||
const voteCreated = await this.voteRepository.create(vote);
|
||||
const voteEntity = Vote.hydrate<Vote>(voteCreated, { strategy: "excludeAll" });
|
||||
await this.notificationBuilder.sendVoteNotification(voteEntity);
|
||||
return voteCreated;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user