From 3481165bc501f4b0891ad95c57f9390bba855c99 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 6 Jan 2020 21:38:29 -0300 Subject: [PATCH] everything: use winter --- litecord/blueprints/auth.py | 4 ++-- litecord/blueprints/channel/messages.py | 4 ++-- litecord/blueprints/channel/pins.py | 6 +++--- litecord/blueprints/channels.py | 4 ++-- litecord/blueprints/dm_channels.py | 4 ++-- litecord/blueprints/dms.py | 4 ++-- litecord/blueprints/guild/channels.py | 4 ++-- litecord/blueprints/guild/emoji.py | 4 ++-- litecord/blueprints/guilds.py | 10 +++++----- litecord/blueprints/user/billing.py | 12 ++++++------ litecord/blueprints/user/billing_job.py | 4 ++-- litecord/blueprints/webhooks.py | 6 +++--- litecord/system_messages.py | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/litecord/blueprints/auth.py b/litecord/blueprints/auth.py index 4b60a69..917a3f4 100644 --- a/litecord/blueprints/auth.py +++ b/litecord/blueprints/auth.py @@ -29,7 +29,7 @@ from litecord.auth import token_check from litecord.common.users import create_user from litecord.schemas import validate, REGISTER, REGISTER_WITH_INVITE from litecord.errors import BadRequest -from litecord.snowflake import get_snowflake +from winter import gewinter from .invites import use_invite log = Logger(__name__) @@ -186,7 +186,7 @@ async def _logout(): @bp.route("/fingerprint", methods=["POST"]) async def _fingerprint(): """No idea what this route is about.""" - fingerprint_id = get_snowflake() + fingerprint_id = gewinter() fingerprint = f"{fingerprint_id}.{secrets.token_urlsafe(32)}" return jsonify({"fingerprint": fingerprint}) diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index f46bae8..f2c7088 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -26,7 +26,7 @@ from litecord.blueprints.auth import token_check from litecord.blueprints.checks import channel_check, channel_perm_check from litecord.errors import MessageNotFound, Forbidden from litecord.enums import MessageType, ChannelType, GUILD_CHANS -from litecord.snowflake import get_snowflake +from winter import gewinter from litecord.schemas import validate, MESSAGE_CREATE from litecord.utils import pg_set_json, query_tuple_from_args, extract_limit from litecord.permissions import get_permissions @@ -148,7 +148,7 @@ async def _dm_pre_dispatch(channel_id, peer_id): async def create_message( channel_id: int, actual_guild_id: int, author_id: int, data: dict ) -> int: - message_id = get_snowflake() + message_id = gewinter() async with app.db.acquire() as conn: await pg_set_json(conn) diff --git a/litecord/blueprints/channel/pins.py b/litecord/blueprints/channel/pins.py index 5cdef0a..1a959fe 100644 --- a/litecord/blueprints/channel/pins.py +++ b/litecord/blueprints/channel/pins.py @@ -21,7 +21,7 @@ from quart import Blueprint, current_app as app, jsonify from litecord.auth import token_check from litecord.blueprints.checks import channel_check, channel_perm_check -from litecord.snowflake import snowflake_datetime +from winter imporwinter_datetime from litecord.types import timestamp_ from litecord.system_messages import send_sys_message @@ -104,7 +104,7 @@ async def add_pin(channel_id, message_id): channel_id, ) - timestamp = snowflake_datetime(row["message_id"]) + timestamp winter_datetime(row["message_id"]) await app.dispatcher.dispatch( "channel", @@ -147,7 +147,7 @@ async def delete_pin(channel_id, message_id): channel_id, ) - timestamp = snowflake_datetime(row["message_id"]) + timestamp winter_datetime(row["message_id"]) await app.dispatcher.dispatch( "channel", diff --git a/litecord/blueprints/channels.py b/litecord/blueprints/channels.py index 701c141..bffdb74 100644 --- a/litecord/blueprints/channels.py +++ b/litecord/blueprints/channels.py @@ -41,7 +41,7 @@ from litecord.system_messages import send_sys_message from litecord.blueprints.dm_channels import gdm_remove_recipient, gdm_destroy from litecord.utils import search_result_from_list from litecord.embed.messages import process_url_embed, msg_update_embeds -from litecord.snowflake import snowflake_datetime +from winter imporwinter_datetime from litecord.common.channels import channel_ack log = Logger(__name__) @@ -788,7 +788,7 @@ async def bulk_delete(channel_id: int): # we must error. a cuter behavior would be returning the message ids # that were deleted, ignoring the 2 week+ old ones. for message_id in message_ids: - message_dt = snowflake_datetime(message_id) + message_dt winter_datetime(message_id) delta = datetime.datetime.utcnow() - message_dt if delta.days > 14: diff --git a/litecord/blueprints/dm_channels.py b/litecord/blueprints/dm_channels.py index 76bd24a..d428b7f 100644 --- a/litecord/blueprints/dm_channels.py +++ b/litecord/blueprints/dm_channels.py @@ -24,7 +24,7 @@ from litecord.blueprints.auth import token_check from litecord.blueprints.checks import channel_check from litecord.enums import ChannelType, MessageType from litecord.errors import BadRequest, Forbidden -from litecord.snowflake import get_snowflake +from winter import gewinter from litecord.system_messages import send_sys_message from litecord.pubsub.channel import gdm_recipient_view @@ -59,7 +59,7 @@ async def gdm_create(user_id, peer_id) -> int: Returns the new GDM id. """ - channel_id = get_snowflake() + channel_id = gewinter() await app.db.execute( """ diff --git a/litecord/blueprints/dms.py b/litecord/blueprints/dms.py index 2a50837..6bd4be5 100644 --- a/litecord/blueprints/dms.py +++ b/litecord/blueprints/dms.py @@ -26,7 +26,7 @@ from logbook import Logger from ..schemas import validate, CREATE_DM, CREATE_GROUP_DM from ..enums import ChannelType -from ..snowflake import get_snowflake +from winter import gewinter from .auth import token_check @@ -70,7 +70,7 @@ async def create_dm(user_id, recipient_id): # if no dm was found, create a new one - dm_id = get_snowflake() + dm_id = gewinter() await app.db.execute( """ INSERT INTO channels (id, channel_type) diff --git a/litecord/blueprints/guild/channels.py b/litecord/blueprints/guild/channels.py index de20b95..f618019 100644 --- a/litecord/blueprints/guild/channels.py +++ b/litecord/blueprints/guild/channels.py @@ -20,7 +20,7 @@ along with this program. If not, see . from quart import Blueprint, request, current_app as app, jsonify from litecord.blueprints.auth import token_check -from litecord.snowflake import get_snowflake +from winter import gewinter from litecord.errors import BadRequest from litecord.enums import ChannelType from litecord.blueprints.guild.roles import gen_pairs @@ -56,7 +56,7 @@ async def create_channel(guild_id): if channel_type not in (ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE): raise BadRequest("Invalid channel type") - new_channel_id = get_snowflake() + new_channel_id = gewinter() await create_guild_channel(guild_id, new_channel_id, channel_type, **j) # TODO: do a better method diff --git a/litecord/blueprints/guild/emoji.py b/litecord/blueprints/guild/emoji.py index 9a5a7d5..b16ecce 100644 --- a/litecord/blueprints/guild/emoji.py +++ b/litecord/blueprints/guild/emoji.py @@ -22,7 +22,7 @@ from quart import Blueprint, jsonify, current_app as app, request from litecord.auth import token_check from litecord.blueprints.checks import guild_check, guild_perm_check from litecord.schemas import validate, NEW_EMOJI, PATCH_EMOJI -from litecord.snowflake import get_snowflake +from winter import gewinter from litecord.types import KILOBYTES from litecord.images import parse_data_uri from litecord.errors import BadRequest @@ -93,7 +93,7 @@ async def _put_emoji(guild_id): mime, _ = parse_data_uri(j["image"]) await _guild_emoji_size_check(guild_id, mime) - emoji_id = get_snowflake() + emoji_id = gewinter() icon = await app.icons.put( "emoji", diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index df385eb..41ce520 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -29,7 +29,7 @@ from litecord.common.guilds import ( ) from ..auth import token_check -from ..snowflake import get_snowflake +from winter import gewinter from ..enums import ChannelType from ..schemas import ( validate, @@ -79,7 +79,7 @@ async def guild_create_roles_prep(guild_id: int, roles: list): async def guild_create_channels_prep(guild_id: int, channels: list): """Create channels pre-guild create""" for channel_raw in channels: - channel_id = get_snowflake() + channel_id = gewinter() ctype = ChannelType(channel_raw["type"]) await create_guild_channel(guild_id, channel_id, ctype) @@ -120,7 +120,7 @@ async def create_guild(): user_id = await token_check() j = validate(await request.get_json(), GUILD_CREATE) - guild_id = get_snowflake() + guild_id = gewinter() if "icon" in j: image = await put_guild_icon(guild_id, j["icon"]) @@ -152,7 +152,7 @@ async def create_guild(): # we also don't use create_role because the id of the role # is the same as the id of the guild, and create_role - # generates a new snowflake. + # generates a newinter. await app.db.execute( """ INSERT INTO roles (id, guild_id, name, position, permissions) @@ -177,7 +177,7 @@ async def create_guild(): ) # create a single #general channel. - general_id = get_snowflake() + general_id = gewinter() await create_guild_channel( guild_id, general_id, ChannelType.GUILD_TEXT, name="general" diff --git a/litecord/blueprints/user/billing.py b/litecord/blueprints/user/billing.py index 3bf770d..ba6d07d 100644 --- a/litecord/blueprints/user/billing.py +++ b/litecord/blueprints/user/billing.py @@ -26,7 +26,7 @@ from logbook import Logger from litecord.auth import token_check from litecord.schemas import validate -from litecord.snowflake import snowflake_datetime, get_snowflake +from winter imporwinter_datetime, gewinter from litecord.errors import BadRequest from litecord.types import timestamp_, HOURS from litecord.enums import UserFlags, PremiumType @@ -240,7 +240,7 @@ async def get_payment(payment_id: int): drow.pop("subscription_id") drow.pop("user_id") - drow["created_at"] = snowflake_datetime(int(drow["id"])) + drow["created_at"] winter_datetime(int(drow["id"])) drow["payment_source"] = await get_payment_source(row["user_id"], row["source_id"]) @@ -253,7 +253,7 @@ async def create_payment(subscription_id): """Create a payment.""" sub = await get_subscription(subscription_id) - new_id = get_snowflake() + new_id = gewinter() amount = AMOUNTS[sub["payment_gateway_plan_id"]] @@ -302,7 +302,7 @@ async def process_subscription(subscription_id: int): subscription_id, ) - first_payment_ts = snowflake_datetime(first_payment_id) + first_payment_ts winter_datetime(first_payment_id) premium_since = await app.db.fetchval( """ @@ -393,7 +393,7 @@ async def _create_payment_source(): user_id = await token_check() j = validate(await request.get_json(), PAYMENT_SOURCE) - new_source_id = get_snowflake() + new_source_id = gewinter() await app.db.execute( """ @@ -437,7 +437,7 @@ async def _create_subscription(): "premium_year_tier_2": "1 year", }[plan_id] - new_id = get_snowflake() + new_id = gewinter() await app.db.execute( f""" diff --git a/litecord/blueprints/user/billing_job.py b/litecord/blueprints/user/billing_job.py index ee50c33..b2a6a9d 100644 --- a/litecord/blueprints/user/billing_job.py +++ b/litecord/blueprints/user/billing_job.py @@ -34,7 +34,7 @@ from litecord.blueprints.user.billing import ( process_subscription, ) -from litecord.snowflake import snowflake_datetime +from winter imporwinter_datetime from litecord.types import MINUTES log = Logger(__name__) @@ -71,7 +71,7 @@ async def _process_user_payments(user_id: int): # calculate the difference between this payment # and now. now = datetime.datetime.now() - payment_tstamp = snowflake_datetime(int(payment_data["id"])) + payment_tstamp winter_datetime(int(payment_data["id"])) delta = now - payment_tstamp diff --git a/litecord/blueprints/webhooks.py b/litecord/blueprints/webhooks.py index bb3668b..39a2dbf 100644 --- a/litecord/blueprints/webhooks.py +++ b/litecord/blueprints/webhooks.py @@ -39,7 +39,7 @@ from litecord.schemas import ( WEBHOOK_MESSAGE_CREATE, ) from litecord.enums import ChannelType -from litecord.snowflake import get_snowflake +from winter import gewinter from litecord.utils import async_map from litecord.errors import WebhookNotFound, Unauthorized, ChannelNotFound, BadRequest @@ -173,7 +173,7 @@ async def create_webhook(channel_id: int): guild_id = await app.storage.guild_from_channel(channel_id) - webhook_id = get_snowflake() + webhook_id = gewinter() # I'd say generating a full fledged token with itsdangerous is # relatively wasteful since webhooks don't even have a password_hash, @@ -348,7 +348,7 @@ async def del_webhook_tokened(webhook_id, webhook_token): async def create_message_webhook(guild_id, channel_id, webhook_id, data): """Create a message, but for webhooks only.""" - message_id = get_snowflake() + message_id = gewinter() async with app.db.acquire() as conn: await pg_set_json(conn) diff --git a/litecord/system_messages.py b/litecord/system_messages.py index bc63717..c7da62f 100644 --- a/litecord/system_messages.py +++ b/litecord/system_messages.py @@ -19,7 +19,7 @@ along with this program. If not, see . from logbook import Logger -from litecord.snowflake import get_snowflake +from winter import get_snowflake from litecord.enums import MessageType log = Logger(__name__)