Initial commit
This commit is contained in:
commit
054f182215
17 files changed
+1312
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import xmpp_api.api.bot as bot_api
|
||||
import xmpp_api.db.bot as bot_db
|
||||
|
||||
|
||||
def bot_constraint_to_db(constraint: bot_api.BotConstraint) -> bot_db.BotConstraint:
|
||||
match constraint:
|
||||
case bot_api.BotDomainConstraint:
|
||||
return bot_db.BotDomainConstraint(
|
||||
domains=constraint.domains,
|
||||
)
|
||||
case _:
|
||||
# TODO: Proper exception type
|
||||
raise Exception()
|
||||
|
||||
|
||||
def bot_constraint_from_db(constraint: bot_db.BotConstraint) -> bot_api.BotConstraint:
|
||||
match constraint:
|
||||
case bot_db.BotDomainConstraint:
|
||||
return bot_api.BotDomainConstraint(
|
||||
domains=constraint.domains,
|
||||
)
|
||||
case _:
|
||||
# TODO: Proper exception type
|
||||
raise Exception()
|
||||
@@ -0,0 +1,5 @@
|
||||
import uuid as py_uuid
|
||||
|
||||
|
||||
def uuid() -> str:
|
||||
return py_uuid.uuid4().hex
|
||||
@@ -0,0 +1,6 @@
|
||||
from secrets import token_bytes
|
||||
|
||||
|
||||
def generate_token(length: int = 32) -> str:
|
||||
# TODO: PBKDF2?
|
||||
return token_bytes(length).hex()
|
||||
Reference in new issue
Block a user