- plugins/federations.js +79 -0
plugins/federations.js
CHANGED
@@ -333,5 +333,84 @@ FedsRoutes.post("/api/v2/federation/ban", authenticateApiKey, apiLimiter, async
|
|
333 |
}
|
334 |
});
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
|
337 |
export { FedsRoutes };
|
|
|
333 |
}
|
334 |
});
|
335 |
|
336 |
+
/**
|
337 |
+
* @swagger
|
338 |
+
* /api/v2/federation/ban-check:
|
339 |
+
* post:
|
340 |
+
* summary: Check if a user is banned in a federation
|
341 |
+
* tags: [Federation]
|
342 |
+
* description: Checks whether a user is banned in a specific federation using UUID and user ID.
|
343 |
+
* security:
|
344 |
+
* - apiKeyAuth: []
|
345 |
+
* requestBody:
|
346 |
+
* required: true
|
347 |
+
* content:
|
348 |
+
* application/json:
|
349 |
+
* schema:
|
350 |
+
* type: object
|
351 |
+
* properties:
|
352 |
+
* federation_uuid:
|
353 |
+
* type: string
|
354 |
+
* description: UUID of the federation.
|
355 |
+
* user_id:
|
356 |
+
* type: integer
|
357 |
+
* description: User ID to check.
|
358 |
+
* parameters:
|
359 |
+
* - in: header
|
360 |
+
* name: x-api-key
|
361 |
+
* required: true
|
362 |
+
* description: API key for authentication.
|
363 |
+
* schema:
|
364 |
+
* type: string
|
365 |
+
* responses:
|
366 |
+
* 200:
|
367 |
+
* description: Ban status of the user in the federation.
|
368 |
+
* content:
|
369 |
+
* application/json:
|
370 |
+
* schema:
|
371 |
+
* type: object
|
372 |
+
* properties:
|
373 |
+
* federation:
|
374 |
+
* type: string
|
375 |
+
* example: "AkenoX Federation"
|
376 |
+
* user_id:
|
377 |
+
* type: integer
|
378 |
+
* example: 12345
|
379 |
+
* is_banned:
|
380 |
+
* type: boolean
|
381 |
+
* example: true
|
382 |
+
* 400:
|
383 |
+
* description: Missing federation UUID or invalid user ID.
|
384 |
+
* 404:
|
385 |
+
* description: Federation not found.
|
386 |
+
* 500:
|
387 |
+
* description: Internal server error.
|
388 |
+
*/
|
389 |
+
FedsRoutes.post("/api/v2/federation/ban-check", authenticateApiKey, async (req, res) => {
|
390 |
+
try {
|
391 |
+
const { federation_uuid, user_id } = req.body;
|
392 |
+
|
393 |
+
if (!federation_uuid || !user_id || isNaN(user_id)) {
|
394 |
+
return res.status(400).json({ error: "Federation UUID and valid user ID required." });
|
395 |
+
}
|
396 |
+
|
397 |
+
const federation = await Federation.findOne({ uuid: federation_uuid });
|
398 |
+
|
399 |
+
if (!federation) {
|
400 |
+
return res.status(404).json({ error: "Federation not found." });
|
401 |
+
}
|
402 |
+
|
403 |
+
const isBanned = federation.banned_users.includes(user_id);
|
404 |
+
|
405 |
+
res.json({
|
406 |
+
federation: federation.name,
|
407 |
+
user_id,
|
408 |
+
is_banned: isBanned
|
409 |
+
});
|
410 |
+
|
411 |
+
} catch (error) {
|
412 |
+
res.status(500).json({ error: `Failed to check ban status: ${error.message}` });
|
413 |
+
}
|
414 |
+
});
|
415 |
|
416 |
export { FedsRoutes };
|