use community outbox properly

This commit is contained in:
rimu 2024-02-21 08:36:47 +13:00
parent 8ce71bdd54
commit 46bca83e2a
3 changed files with 46 additions and 1 deletions

View file

@ -425,6 +425,7 @@ def actor_json_to_model(activity_json, address, server):
ap_profile_id=activity_json['id'].lower(),
ap_followers_url=activity_json['followers'],
ap_inbox_url=activity_json['endpoints']['sharedInbox'],
ap_outbox_url=activity_json['outbox'],
ap_moderators_url=mods_url,
ap_fetched_at=utcnow(),
ap_domain=server,

View file

@ -91,7 +91,7 @@ def retrieve_mods_and_backfill(community_id: int):
# download 50 old posts
if community.ap_public_url:
outbox_request = get_request(community.ap_public_url + '/outbox', headers={'Accept': 'application/activity+json'})
outbox_request = get_request(community.ap_outbox_url, headers={'Accept': 'application/activity+json'})
if outbox_request.status_code == 200:
outbox_data = outbox_request.json()
outbox_request.close()

View file

@ -0,0 +1,44 @@
"""community outbox url
Revision ID: a937c8721612
Revises: 8ca0f0789040
Create Date: 2024-02-21 08:14:23.088264
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a937c8721612'
down_revision = '8ca0f0789040'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.add_column(sa.Column('ap_outbox_url', sa.String(length=255), nullable=True))
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.add_column(sa.Column('email_unread', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('email_unread_sent', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('email_messages', sa.Boolean(), nullable=True))
batch_op.add_column(sa.Column('email_messages_sent', sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.drop_column('email_messages_sent')
batch_op.drop_column('email_messages')
batch_op.drop_column('email_unread_sent')
batch_op.drop_column('email_unread')
with op.batch_alter_table('community', schema=None) as batch_op:
batch_op.drop_column('ap_outbox_url')
# ### end Alembic commands ###