From e065880085400c6047b118b9204cd6792920344e Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Fri, 9 Dec 2022 11:59:24 +0100 Subject: [PATCH] Add ActivityPub mentions --- activitypub.php | 5 ++ includes/class-mention.php | 63 +++++++++++++++++++ includes/functions.php | 6 +- includes/model/class-activity.php | 10 +-- includes/model/class-post.php | 12 ++++ includes/rest/class-webfinger.php | 43 +++++++++++++ .../class-friends-feed-parser-activitypub.php | 24 ++++++- .../notiz-blog-author-matthias-pfefferle.json | 22 +++++++ .../notiz-blog-well-known-webfinger.json | 22 +++++++ tests/test-class-activitypub-mention.php | 34 ++++++++++ ...-class-friends-feed-parser-activitypub.php | 52 ++++++++++----- tests/test-functions.php | 7 +++ 12 files changed, 273 insertions(+), 27 deletions(-) create mode 100644 includes/class-mention.php create mode 100644 tests/fixtures/notiz-blog-author-matthias-pfefferle.json create mode 100644 tests/fixtures/notiz-blog-well-known-webfinger.json create mode 100644 tests/test-class-activitypub-mention.php create mode 100644 tests/test-functions.php diff --git a/activitypub.php b/activitypub.php index 994ef10..991f106 100644 --- a/activitypub.php +++ b/activitypub.php @@ -22,6 +22,8 @@ function init() { \defined( 'ACTIVITYPUB_EXCERPT_LENGTH' ) || \define( 'ACTIVITYPUB_EXCERPT_LENGTH', 400 ); \defined( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS' ) || \define( 'ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS', 3 ); \defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=

)|(?<=
)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' ); + \defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || \define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:[^@]+@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' ); + \defined( 'ACTIVITYPUB_ALLOWED_HTML' ) || \define( 'ACTIVITYPUB_ALLOWED_HTML', '