Explorar o código

fix: only ban if has user_id

poeti8 %!s(int64=6) %!d(string=hai) anos
pai
achega
dd510e3050
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      server/handlers/links.ts

+ 2 - 2
server/handlers/links.ts

@@ -173,12 +173,12 @@ export const ban: Handler = async (req, res) => {
   }
 
   // 5. Ban link owner
-  if (req.body.user) {
+  if (req.body.user && link.user_id) {
     tasks.push(query.user.update({ id: link.user_id }, update));
   }
 
   // 6. Ban all of owner's links
-  if (req.body.userLinks) {
+  if (req.body.userLinks && link.user_id) {
     tasks.push(query.link.update({ user_id: link.user_id }, update));
   }