migration-email-confirm-fix

This commit is contained in:
tonyrewin 2022-11-16 12:23:32 +03:00
parent 803be4ceee
commit f0796cb939
3 changed files with 13 additions and 4 deletions

View File

@ -31,6 +31,7 @@ middleware = [
async def start_up():
await redis.connect()
await storages_init()
views_stat_task = asyncio.create_task(ViewStat.worker())
print(views_stat_task)
reacted_storage_task = asyncio.create_task(ReactedStorage.worker())
@ -41,8 +42,6 @@ async def start_up():
print(topic_stat_task)
git_task = asyncio.create_task(GitTask.git_task_worker())
print(git_task)
await storages_init()
print()
async def shutdown():

View File

@ -7,7 +7,7 @@ import sys
from datetime import datetime
import bs4
from base.redis import redis
from migration.tables.comments import migrate as migrateComment
from migration.tables.comments import migrate_2stage as migrateComment_2stage
from migration.tables.content_items import get_shout_slug
@ -181,7 +181,11 @@ async def all_handle(storage, args):
print("[migration] handle everything")
await users_handle(storage)
await topics_handle(storage)
print("[migration] users and topics are migrated")
await redis.connect()
print("[migration] redis connected")
await shouts_handle(storage, args)
print("[migration] migrating comments")
await comments_handle(storage)
# export_email_subscriptions()
print("[migration] done!")
@ -295,9 +299,9 @@ def create_pgdump():
async def handle_auto():
print("[migration] no option given, auto mode")
url = os.getenv("MONGODB_URL")
if url:
print("[migration] connecting mongo")
mongo_download(url)
bson_handle()
await all_handle(data_load(), sys.argv)

View File

@ -149,6 +149,12 @@ async def migrate(entry, storage):
if entry.get("published"):
r["publishedAt"] = date_parse(entry.get("publishedAt", OLD_DATE))
r["visibility"] = "public"
with local_session() as session:
# update user.emailConfirmed if published
author = session.query(User).where(User.slug == userslug).first()
author.emailConfirmed = True
session.add(author)
session.commit()
else:
r["visibility"] = "authors"
if "deletedAt" in entry: