wrolpi/modules/otp/api.py

38 lines
1,011 B
Python
Raw Normal View History

from sanic import response
from sanic.request import Request
from sanic_ext import validate
from sanic_ext.extensions.openapi import openapi
from wrolpi.root_api import get_blueprint
from . import lib, schema
bp = get_blueprint('OTP', '/api/otp')
Squashed commit of the following: commit 1663e1be9e1a9b82521be9ae257e0b91bfdd3199 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:37:25 2021 -0700 Setting downloader to video when a channel schedules it's videos for download. commit a6811f9e87b0754cc7c1dd197ae300f197620bbb Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:33:27 2021 -0700 Setting channel downloader when spreading channel downloads. commit b63c8f132aa00705c1a46dc04c51a4889fcd7ec7 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:28:53 2021 -0700 Fixing DownloadManager.kill commit 120ce7cd2cff981d2af7e8d33d139be9e2b50e13 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:10:12 2021 -0700 Fixing OTP api urls. commit d3b985241b0851c926feafb1b875ab6203057bf2 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:07:48 2021 -0700 Channel Cancel button does not submit form. commit 9d1a0ecd55f08a4bf255030045c1307c3d716157 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:00:53 2021 -0700 A Channel without an existing Download cannot be downloaded. commit e7c920f3825a0f12f5475f01ce11632665cdb3f6 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:41:02 2021 -0700 Fixing typing. commit d56c8fde249e94f858214c16197da1b8a0919422 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:36:02 2021 -0700 Testing bad downloader param. commit e3c57ef674ecdf3bd39df4fe341e516ba0edab92 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:31:35 2021 -0700 Adding __json__ to Downloader for sending them to the FE. Hiding ChannelDownloader because it will be handled specifically. commit 047b50711919b6aa2d4a7fe8e25a963e60d4ee3a Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:20:37 2021 -0700 Downloader can be specified by the user. commit 4a169ba43cfd75edf0db0d89f78ec1bf4c4dfe3a Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:37:30 2021 -0700 Download info a set in create_downloads. commit 8778d53fa1063faffba8e2ba505cd9f0de7be20e Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:21:43 2021 -0700 Fixing Download.info_json name. commit b28bacfd5be6b0df82944b246db7248cc4e3c405 Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:17:53 2021 -0700 Downloader names are in the class, not in the init. commit f5ce952da01540a856eb5a0b084496da5c9279cf Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:07:42 2021 -0700 Download info can be saved during the download process and can be used by the Downloader.
2021-12-30 20:45:11 -07:00
@bp.post('/encrypt_otp')
@openapi.definition(
summary='Encrypt a message with OTP.',
body=schema.EncryptOTPRequest,
)
@validate(schema.EncryptOTPRequest)
2022-02-16 21:57:27 -07:00
async def post_encrypt_otp(_: Request, body: schema.EncryptOTPRequest):
data = lib.encrypt_otp(body.otp, body.plaintext)
return response.json(data)
Squashed commit of the following: commit 1663e1be9e1a9b82521be9ae257e0b91bfdd3199 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:37:25 2021 -0700 Setting downloader to video when a channel schedules it's videos for download. commit a6811f9e87b0754cc7c1dd197ae300f197620bbb Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:33:27 2021 -0700 Setting channel downloader when spreading channel downloads. commit b63c8f132aa00705c1a46dc04c51a4889fcd7ec7 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:28:53 2021 -0700 Fixing DownloadManager.kill commit 120ce7cd2cff981d2af7e8d33d139be9e2b50e13 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:10:12 2021 -0700 Fixing OTP api urls. commit d3b985241b0851c926feafb1b875ab6203057bf2 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:07:48 2021 -0700 Channel Cancel button does not submit form. commit 9d1a0ecd55f08a4bf255030045c1307c3d716157 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 19:00:53 2021 -0700 A Channel without an existing Download cannot be downloaded. commit e7c920f3825a0f12f5475f01ce11632665cdb3f6 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:41:02 2021 -0700 Fixing typing. commit d56c8fde249e94f858214c16197da1b8a0919422 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:36:02 2021 -0700 Testing bad downloader param. commit e3c57ef674ecdf3bd39df4fe341e516ba0edab92 Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:31:35 2021 -0700 Adding __json__ to Downloader for sending them to the FE. Hiding ChannelDownloader because it will be handled specifically. commit 047b50711919b6aa2d4a7fe8e25a963e60d4ee3a Author: Roland <roland@learningselfreliance.com> Date: Thu Dec 30 18:20:37 2021 -0700 Downloader can be specified by the user. commit 4a169ba43cfd75edf0db0d89f78ec1bf4c4dfe3a Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:37:30 2021 -0700 Download info a set in create_downloads. commit 8778d53fa1063faffba8e2ba505cd9f0de7be20e Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:21:43 2021 -0700 Fixing Download.info_json name. commit b28bacfd5be6b0df82944b246db7248cc4e3c405 Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:17:53 2021 -0700 Downloader names are in the class, not in the init. commit f5ce952da01540a856eb5a0b084496da5c9279cf Author: Roland <roland@learningselfreliance.com> Date: Tue Dec 28 18:07:42 2021 -0700 Download info can be saved during the download process and can be used by the Downloader.
2021-12-30 20:45:11 -07:00
@bp.post('/decrypt_otp')
@openapi.definition(
summary='Decrypt a message with OTP.',
body=schema.DecryptOTPRequest,
)
@validate(schema.DecryptOTPRequest)
2022-02-16 21:57:27 -07:00
async def post_decrypt_otp(_: Request, body: schema.DecryptOTPRequest):
data = lib.decrypt_otp(body.otp, body.ciphertext)
return response.json(data)
@bp.get('/html')
async def get_new_otp_html(_: Request):
body = lib.generate_html()
return response.html(body)