[mastodon] Dismiss old notifications in the migration script, so they aren't reposted by ticketfrei3
This commit is contained in:
parent
e9eb98dba8
commit
061d29325f
|
@ -5,6 +5,7 @@ from os import urandom
|
|||
from tortoise import Tortoise
|
||||
from tortoise.exceptions import DoesNotExist
|
||||
import asyncio
|
||||
from mastodon import Mastodon
|
||||
|
||||
from kibicara.model import Admin, Hood, IncludePattern, ExcludePattern
|
||||
from kibicara.platforms.mastodon.model import MastodonInstance, MastodonAccount
|
||||
|
@ -148,6 +149,7 @@ class Main:
|
|||
access_token=access_token,
|
||||
enabled=mastodon_enabled,
|
||||
)
|
||||
await dismiss_notifications(hood)
|
||||
print(f"Mastodon: {instance_url}, {access_token}")
|
||||
|
||||
telegram_account = self.old_db.execute(
|
||||
|
@ -206,3 +208,18 @@ class Main:
|
|||
)
|
||||
print(f"Twitter: last ID: {seen_tweet}")
|
||||
await Tortoise.close_connections()
|
||||
|
||||
|
||||
async def dismiss_notifications(hood):
|
||||
model = await MastodonAccount.get(hood=hood)
|
||||
await model.fetch_related("instance")
|
||||
account = Mastodon(
|
||||
client_id=model.instance.client_id,
|
||||
client_secret=model.instance.client_secret,
|
||||
api_base_url=model.instance.name,
|
||||
access_token=model.access_token,
|
||||
)
|
||||
notifications = account.notifications()
|
||||
for status in notifications:
|
||||
account.notifications_dismiss(status["id"])
|
||||
print(f"Dismissed {len(notifications)} notifications on Mastodon.")
|
||||
|
|
Loading…
Reference in a new issue