make sure lastUpdated is updated on SSH push too
+ 26
- 1
app/controllers/ssh-auth.ts
@@ -43,13 +43,38 @@ const onSSHAuth: ReqHandler<AppRouteParams, AppRoute.SSH_AUTH> = async (
   }
 
   const isAuthorizationValid = await gitService.authorizationResolver(
-    repoSlug.replace(/\.git$/, "") + ".pub",
+    repoSlug.replace(/\.git$/, "") + ".pub", // indicates publicKey auth
     {
       username,
       password: publicKey,
     }
   );
 
+  if (isAuthorizationValid) {
+    const [orgSlug, repoName] = repoSlug.replace(/\.git$/, "").split("/");
+    request.prisma.repository
+      .findFirst({
+        where: {
+          slug: repoName,
+          organization: {
+            slug: orgSlug,
+          },
+        },
+      })
+      .then(async (repo) => {
+        if (repo == null) return Promise.resolve(null);
+        const updatedRepo = await request.prisma.repository.update({
+          where: {
+            id: repo.id,
+          },
+          data: {
+            lastPushedAt: new Date(Date.now()),
+          },
+        });
+        return updatedRepo;
+      });
+  }
+
   reply.status(isAuthorizationValid ? 200 : 403).send({
     success: isAuthorizationValid,
     authMode,