Skip to content

Commit ea31d19

Browse files
committed
add audit log statements to linkry
1 parent 6323aaf commit ea31d19

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/api/routes/linkry.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import {
4848
getAllLinks,
4949
} from "api/functions/linkry.js";
5050
import { intersection } from "api/plugins/auth.js";
51+
import { createAuditLogEntry } from "api/functions/auditLog.js";
52+
import { Modules } from "common/modules.js";
5153

5254
type OwnerRecord = {
5355
slug: string;
@@ -453,6 +455,15 @@ const linkryRoutes: FastifyPluginAsync = async (fastify, _options) => {
453455
message: "Failed to save redirect to Cloudfront KV store.",
454456
});
455457
}
458+
await createAuditLogEntry({
459+
dynamoClient: fastify.dynamoClient,
460+
entry: {
461+
module: Modules.LINKRY,
462+
actor: request.username!,
463+
target: request.body.slug,
464+
message: `Created redirect to "${request.body.redirect}"`,
465+
},
466+
});
456467
return reply.status(201).send();
457468
},
458469
);
@@ -575,7 +586,6 @@ const linkryRoutes: FastifyPluginAsync = async (fastify, _options) => {
575586
},
576587
},
577588
];
578-
console.log(JSON.stringify(TransactItems));
579589
try {
580590
await fastify.dynamoClient.send(
581591
new TransactWriteItemsCommand({ TransactItems }),
@@ -623,6 +633,15 @@ const linkryRoutes: FastifyPluginAsync = async (fastify, _options) => {
623633
message: "Failed to delete redirect at Cloudfront KV store.",
624634
});
625635
}
636+
await createAuditLogEntry({
637+
dynamoClient: fastify.dynamoClient,
638+
entry: {
639+
module: Modules.LINKRY,
640+
actor: request.username!,
641+
target: slug,
642+
message: `Deleted short link redirect."`,
643+
},
644+
});
626645
reply.code(200).send();
627646
},
628647
);

src/common/modules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export enum Modules {
55
TICKETS = "tickets",
66
EMAIL_NOTIFICATION = "emailNotification",
77
PROVISION_NEW_MEMBER = "provisionNewMember",
8-
MOBILE_WALLET = "mobileWallet"
8+
MOBILE_WALLET = "mobileWallet",
9+
LINKRY = "linkry"
910
}

0 commit comments

Comments
 (0)