Skip to content

Commit

Permalink
feat: send preSigned url to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
m-paice committed Dec 16, 2024
1 parent 14084fe commit 0138f33
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vtru-studio-websocket",
"version": "1.1.40",
"version": "1.1.41",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 12 additions & 0 deletions src/controllers/preSignedURL/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ export const start = async () => {
const parsedMessage = JSON.parse(content.trim()) as AssetEnvelope;

const sockets = await io.sockets.in('creators').fetchSockets();
const socketsAdmin = await io.sockets.in('admins').fetchSockets();

logger('sockets', sockets);
logger('socketsAdmin', socketsAdmin);

sockets.forEach((socket) => {
if (socket.data.id === parsedMessage.creatorId) {
Expand All @@ -67,6 +69,16 @@ export const start = async () => {
}
});

socketsAdmin.forEach((socket) => {
if (socket.data.id === parsedMessage.userId) {
socket.emit('preSignedURL', {
preSignedURL: parsedMessage.preSignedURL,
transactionId: parsedMessage.transactionId,
path: parsedMessage.path,
});
}
});

channel.ack(message);
return;
} catch (parsingError) {
Expand Down
1 change: 1 addition & 0 deletions src/controllers/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface AssetEnvelope {
preSignedURL: string;
creatorId: string;
userId: string; // user admin
transactionId: string;
path: string;
origin: string;
Expand Down

0 comments on commit 0138f33

Please sign in to comment.