migration-email-confirm-fix

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

View File

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

View File

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

View File

@ -149,6 +149,12 @@ async def migrate(entry, storage):
if entry.get("published"): if entry.get("published"):
r["publishedAt"] = date_parse(entry.get("publishedAt", OLD_DATE)) r["publishedAt"] = date_parse(entry.get("publishedAt", OLD_DATE))
r["visibility"] = "public" 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.update(author)
session.commit()
else: else:
r["visibility"] = "authors" r["visibility"] = "authors"
if "deletedAt" in entry: if "deletedAt" in entry: