varied fixes due to sed fuckups

This commit is contained in:
Luna 2020-01-06 22:55:20 -03:00
parent 3481165bc5
commit a76460bea1
12 changed files with 32 additions and 32 deletions

View File

@ -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 winter import gewinter
from winter import get_snowflake
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 = gewinter()
fingerprint_id = get_snowflake()
fingerprint = f"{fingerprint_id}.{secrets.token_urlsafe(32)}"
return jsonify({"fingerprint": fingerprint})

View File

@ -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 winter import gewinter
from winter import get_snowflake
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 = gewinter()
message_id = get_snowflake()
async with app.db.acquire() as conn:
await pg_set_json(conn)

View File

@ -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 winter imporwinter_datetime
from winter import snowflake_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 winter_datetime(row["message_id"])
timestamp = snowflake_datetime(row["message_id"])
await app.dispatcher.dispatch(
"channel",
@ -147,7 +147,7 @@ async def delete_pin(channel_id, message_id):
channel_id,
)
timestamp winter_datetime(row["message_id"])
timestamp = snowflake_datetime(row["message_id"])
await app.dispatcher.dispatch(
"channel",

View File

@ -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 winter imporwinter_datetime
from winter import snowflake_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 winter_datetime(message_id)
message_dt = snowflake_datetime(message_id)
delta = datetime.datetime.utcnow() - message_dt
if delta.days > 14:

View File

@ -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 winter import gewinter
from winter import get_snowflake
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 = gewinter()
channel_id = get_snowflake()
await app.db.execute(
"""

View File

@ -26,7 +26,7 @@ from logbook import Logger
from ..schemas import validate, CREATE_DM, CREATE_GROUP_DM
from ..enums import ChannelType
from winter import gewinter
from winter import get_snowflake
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 = gewinter()
dm_id = get_snowflake()
await app.db.execute(
"""
INSERT INTO channels (id, channel_type)

View File

@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from quart import Blueprint, request, current_app as app, jsonify
from litecord.blueprints.auth import token_check
from winter import gewinter
from winter import get_snowflake
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 = gewinter()
new_channel_id = get_snowflake()
await create_guild_channel(guild_id, new_channel_id, channel_type, **j)
# TODO: do a better method

View File

@ -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 winter import gewinter
from winter import get_snowflake
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 = gewinter()
emoji_id = get_snowflake()
icon = await app.icons.put(
"emoji",

View File

@ -29,7 +29,7 @@ from litecord.common.guilds import (
)
from ..auth import token_check
from winter import gewinter
from winter import get_snowflake
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 = gewinter()
channel_id = get_snowflake()
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 = gewinter()
guild_id = get_snowflake()
if "icon" in j:
image = await put_guild_icon(guild_id, j["icon"])
@ -177,7 +177,7 @@ async def create_guild():
)
# create a single #general channel.
general_id = gewinter()
general_id = get_snowflake()
await create_guild_channel(
guild_id, general_id, ChannelType.GUILD_TEXT, name="general"

View File

@ -26,7 +26,7 @@ from logbook import Logger
from litecord.auth import token_check
from litecord.schemas import validate
from winter imporwinter_datetime, gewinter
from winter import snowflake_datetime, get_snowflake
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"] winter_datetime(int(drow["id"]))
drow["created_at"] = snowflake_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 = gewinter()
new_id = get_snowflake()
amount = AMOUNTS[sub["payment_gateway_plan_id"]]
@ -302,7 +302,7 @@ async def process_subscription(subscription_id: int):
subscription_id,
)
first_payment_ts winter_datetime(first_payment_id)
first_payment_ts = snowflake_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 = gewinter()
new_source_id = get_snowflake()
await app.db.execute(
"""
@ -437,7 +437,7 @@ async def _create_subscription():
"premium_year_tier_2": "1 year",
}[plan_id]
new_id = gewinter()
new_id = get_snowflake()
await app.db.execute(
f"""

View File

@ -34,7 +34,7 @@ from litecord.blueprints.user.billing import (
process_subscription,
)
from winter imporwinter_datetime
from winter import snowflake_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 winter_datetime(int(payment_data["id"]))
payment_tstamp = snowflake_datetime(int(payment_data["id"]))
delta = now - payment_tstamp

View File

@ -39,7 +39,7 @@ from litecord.schemas import (
WEBHOOK_MESSAGE_CREATE,
)
from litecord.enums import ChannelType
from winter import gewinter
from winter import get_snowflake
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 = gewinter()
webhook_id = get_snowflake()
# 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 = gewinter()
message_id = get_snowflake()
async with app.db.acquire() as conn:
await pg_set_json(conn)