diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 2ae26693..bdb24f65 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -33,7 +33,8 @@ from app.utils import get_request, allowlist_html, get_setting, ap_datetime, mar microblog_content_to_title, is_video_url, \ notification_subscribers, communities_banned_from, actor_contains_blocked_words, \ html_to_text, add_to_modlog_activitypub, joined_communities, \ - moderating_communities, get_task_session, is_video_hosting_site, opengraph_parse, instance_banned + moderating_communities, get_task_session, is_video_hosting_site, opengraph_parse, instance_banned, \ + mastodon_extra_field_link from sqlalchemy import or_ @@ -517,6 +518,8 @@ def refresh_user_profile_task(user_id): user.extra_fields = [] for field_data in activity_json['attachment']: if field_data['type'] == 'PropertyValue': + if 'brammeehan.com') + response = get_request('https://rimu.geek.nz') x = '' if response.status_code == 200: diff --git a/app/models.py b/app/models.py index 06a2eeaf..1049b542 100644 --- a/app/models.py +++ b/app/models.py @@ -2067,7 +2067,7 @@ class UserExtraField(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) label = db.Column(db.String(50)) - text = db.Column(db.String(256)) + text = db.Column(db.String(1024)) class UserBlock(db.Model): diff --git a/app/utils.py b/app/utils.py index 81aff02d..46bbca9f 100644 --- a/app/utils.py +++ b/app/utils.py @@ -384,6 +384,12 @@ def html_to_text(html) -> str: return soup.get_text() +def mastodon_extra_field_link(extra_field: str) -> str: + soup = BeautifulSoup(extra_field, 'html.parser') + for tag in soup.find_all('a'): + return tag['href'] + + def microblog_content_to_title(html: str) -> str: title = '' if '

' in html: diff --git a/migrations/versions/9df13396fd54_extra_field_length.py b/migrations/versions/9df13396fd54_extra_field_length.py new file mode 100644 index 00000000..2d55a679 --- /dev/null +++ b/migrations/versions/9df13396fd54_extra_field_length.py @@ -0,0 +1,38 @@ +"""extra field length + +Revision ID: 9df13396fd54 +Revises: 8758c0a94f82 +Create Date: 2025-01-01 15:30:42.165900 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '9df13396fd54' +down_revision = '8758c0a94f82' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user_extra_field', schema=None) as batch_op: + batch_op.alter_column('text', + existing_type=sa.VARCHAR(length=256), + type_=sa.String(length=1024), + existing_nullable=True) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user_extra_field', schema=None) as batch_op: + batch_op.alter_column('text', + existing_type=sa.String(length=1024), + type_=sa.VARCHAR(length=256), + existing_nullable=True) + + # ### end Alembic commands ###