randydev commited on
Commit
03e6c56
1 Parent(s): 664590f

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +40 -41
main.py CHANGED
@@ -167,6 +167,46 @@ class YouTubeSearch(BaseModel):
167
  query: str
168
  limit: int = 7
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  def secs_to_mins(secs: int) -> str:
171
  mins, secs = divmod(secs, 60)
172
  return f"{mins}:{secs}"
@@ -432,47 +472,6 @@ async def serve_file(filename: str):
432
  content={"error": "File not found"}
433
  )
434
 
435
- class FedBans(BaseModel):
436
- user_id: int
437
- hashtag: str
438
- reason: str
439
-
440
- class GetsaFedBans(BaseModel):
441
- user_id: int
442
-
443
- def get_all_api_keys():
444
- user = collection.find({})
445
- api_keys = []
446
- for x in user:
447
- api_key = x.get("ryuzaki_api_key")
448
- if api_key:
449
- api_keys.append(api_key)
450
- return api_keys
451
-
452
- def get_all_fedbans_api_keys():
453
- user = collection.find({})
454
- api_keys = []
455
- for x in user:
456
- api_key = x.get("fedbans_api_key")
457
- if api_key:
458
- api_keys.append(api_key)
459
- return api_keys
460
-
461
-
462
- def validate_api_key(api_key: str = Header(...)):
463
- USERS_API_KEYS = get_all_api_keys()
464
- if api_key not in USERS_API_KEYS:
465
- raise HTTPException(status_code=401, detail="Invalid API key")
466
-
467
- def validate_api_key_only_devs(api_key: str = Header(...)):
468
- if api_key not in ONLY_DEVELOPER_API_KEYS:
469
- raise HTTPException(status_code=401, detail="Invalid API key")
470
-
471
- def validate_api_key_fedbans(api_key: str = Header(...)):
472
- USERS_API_KEYS = get_all_fedbans_api_keys()
473
- if api_key not in USERS_API_KEYS:
474
- raise HTTPException(status_code=401, detail="Invalid API key")
475
-
476
  RAMDOM_STATUS = [
477
  "civilian",
478
  "wanted",
 
167
  query: str
168
  limit: int = 7
169
 
170
+ class FedBans(BaseModel):
171
+ user_id: int
172
+ hashtag: str
173
+ reason: str
174
+
175
+ class GetsaFedBans(BaseModel):
176
+ user_id: int
177
+
178
+ def get_all_api_keys():
179
+ user = collection.find({})
180
+ api_keys = []
181
+ for x in user:
182
+ api_key = x.get("ryuzaki_api_key")
183
+ if api_key:
184
+ api_keys.append(api_key)
185
+ return api_keys
186
+
187
+ def get_all_fedbans_api_keys():
188
+ user = collection.find({})
189
+ api_keys = []
190
+ for x in user:
191
+ api_key = x.get("fedbans_api_key")
192
+ if api_key:
193
+ api_keys.append(api_key)
194
+ return api_keys
195
+
196
+ def validate_api_key(api_key: str = Header(...)):
197
+ USERS_API_KEYS = get_all_api_keys()
198
+ if api_key not in USERS_API_KEYS:
199
+ raise HTTPException(status_code=401, detail="Invalid API key")
200
+
201
+ def validate_api_key_only_devs(api_key: str = Header(...)):
202
+ if api_key not in ONLY_DEVELOPER_API_KEYS:
203
+ raise HTTPException(status_code=401, detail="Invalid API key")
204
+
205
+ def validate_api_key_fedbans(api_key: str = Header(...)):
206
+ USERS_API_KEYS = get_all_fedbans_api_keys()
207
+ if api_key not in USERS_API_KEYS:
208
+ raise HTTPException(status_code=401, detail="Invalid API key")
209
+
210
  def secs_to_mins(secs: int) -> str:
211
  mins, secs = divmod(secs, 60)
212
  return f"{mins}:{secs}"
 
472
  content={"error": "File not found"}
473
  )
474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  RAMDOM_STATUS = [
476
  "civilian",
477
  "wanted",