randydev commited on
Commit
fc4319b
·
verified ·
1 Parent(s): fc8b3f7

Update plugins/antiban.js

Browse files
Files changed (1) hide show
  1. plugins/antiban.js +17 -14
plugins/antiban.js CHANGED
@@ -205,7 +205,7 @@ AntibanRoutes.get("/api/v1/user/raw/getchat", authenticateApiKey, apiLimiter, as
205
 
206
  /**
207
  * @swagger
208
- * /api/v1/story/task:
209
  * get:
210
  * summary: Telegram User Story Downloader
211
  * tags: [User]
@@ -213,7 +213,7 @@ AntibanRoutes.get("/api/v1/user/raw/getchat", authenticateApiKey, apiLimiter, as
213
  * - in: query
214
  * name: story_url
215
  * required: true
216
- * description: null
217
  * schema:
218
  * type: string
219
  * - in: header
@@ -224,13 +224,14 @@ AntibanRoutes.get("/api/v1/user/raw/getchat", authenticateApiKey, apiLimiter, as
224
  * type: string
225
  * responses:
226
  * 200:
227
- * description: Success
228
  */
229
- AntibanRoutes.get("/api/v1/story/task/:story_url", authenticateApiKey, apiLimiter, async (req, res) => {
230
- const Links = req.params.story_url;
231
  if (!Links) {
232
- return res.status(400).json({ error: "Invalid or missing link" });
233
  }
 
234
  const job_id = uuid.v4();
235
  const newJob = new Job({ job_id, status: "pending" });
236
  await newJob.save();
@@ -246,21 +247,22 @@ AntibanRoutes.get("/api/v1/story/task/:story_url", authenticateApiKey, apiLimite
246
  } catch (err) {
247
  await Job.findOneAndUpdate({ job_id }, { status: "failed" });
248
  }
249
- }, 15000);
 
250
  res.json({ message: "Download started", job_id });
251
  });
252
 
253
  /**
254
  * @swagger
255
- * /api/v1/user/story/task/:job_id:
256
  * get:
257
- * summary: Telegram User Story Task Job
258
  * tags: [User]
259
  * parameters:
260
- * - in: query
261
- * name: story_url
262
  * required: true
263
- * description: null
264
  * schema:
265
  * type: string
266
  * - in: header
@@ -271,16 +273,17 @@ AntibanRoutes.get("/api/v1/story/task/:story_url", authenticateApiKey, apiLimite
271
  * type: string
272
  * responses:
273
  * 200:
274
- * description: Success
275
  */
276
  AntibanRoutes.get("/api/v1/user/story/task/:job_id", authenticateApiKey, apiLimiter, async (req, res) => {
277
  const job = await Job.findOne({ job_id: req.params.job_id });
278
 
279
  if (!job) return res.status(404).json({ error: "Job not found" });
 
280
  res.json({
281
  job_id: job.job_id,
282
  status: job.status,
283
- story_bytes: job.story_bytes
284
  });
285
  });
286
 
 
205
 
206
  /**
207
  * @swagger
208
+ * /api/v1/user/story/task:
209
  * get:
210
  * summary: Telegram User Story Downloader
211
  * tags: [User]
 
213
  * - in: query
214
  * name: story_url
215
  * required: true
216
+ * description: Telegram Story URL to download
217
  * schema:
218
  * type: string
219
  * - in: header
 
224
  * type: string
225
  * responses:
226
  * 200:
227
+ * description: Download started successfully
228
  */
229
+ AntibanRoutes.get("/api/v1/user/story/task", authenticateApiKey, apiLimiter, async (req, res) => {
230
+ const Links = req.query.story_url;
231
  if (!Links) {
232
+ return res.status(400).json({ error: "Invalid or missing story_url" });
233
  }
234
+
235
  const job_id = uuid.v4();
236
  const newJob = new Job({ job_id, status: "pending" });
237
  await newJob.save();
 
247
  } catch (err) {
248
  await Job.findOneAndUpdate({ job_id }, { status: "failed" });
249
  }
250
+ }, 10000);
251
+
252
  res.json({ message: "Download started", job_id });
253
  });
254
 
255
  /**
256
  * @swagger
257
+ * /api/v1/user/story/task/{job_id}:
258
  * get:
259
+ * summary: Check Telegram User Story Download Status
260
  * tags: [User]
261
  * parameters:
262
+ * - in: path
263
+ * name: job_id
264
  * required: true
265
+ * description: Job ID to check download status
266
  * schema:
267
  * type: string
268
  * - in: header
 
273
  * type: string
274
  * responses:
275
  * 200:
276
+ * description: Returns job status and story bytes if completed
277
  */
278
  AntibanRoutes.get("/api/v1/user/story/task/:job_id", authenticateApiKey, apiLimiter, async (req, res) => {
279
  const job = await Job.findOne({ job_id: req.params.job_id });
280
 
281
  if (!job) return res.status(404).json({ error: "Job not found" });
282
+
283
  res.json({
284
  job_id: job.job_id,
285
  status: job.status,
286
+ story_bytes: job.status === "completed" ? job.story_bytes : null
287
  });
288
  });
289