Commit graph

205 commits

Author SHA1 Message Date
Matthias Pfefferle
88675ea6c6
Simple Remote-Reply endpoint. (#866)
* Simple Remote-Comment endpoint.

implements #864

* move sanitize to args

* fix PHPDoc

* change from actions to filters

thanks @akirk for your feedback!

* add generic Interaction hook
2024-09-04 13:37:38 +02:00
Matthias Pfefferle
80ec65ad0a simplified WebFinger code 2024-08-02 10:31:42 +02:00
Matthias Pfefferle
599a6841c8
Add link header (#817)
* init

* add support for API endpoint
2024-07-23 14:56:23 +02:00
Matthias Pfefferle
2e90d76c97
Some Remote-Follow improvements (#805)
* fix css class

* Remember remote profile (#807)

* Revert to @wordpress/scripts@27

* Remember users

* whitespace

* buncha class should be className

* render -> createRoot

* build

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>

* improved some CSS

* show "remember" checkbox only for the remote-reply overlay

* formatting

---------

Co-authored-by: Matt Wiebe <wiebe@automattic.com>
2024-07-15 18:08:09 +02:00
Matthias Pfefferle
c8634d936c fix comments endpoint 2024-07-10 10:45:07 +02:00
Matthias Pfefferle
02678eeec3 fix some WebFinger issues 2024-06-09 14:48:31 +02:00
Matthias Pfefferle
3d1bf1b01b fix content type 2024-06-07 19:59:02 +02:00
Matthias Pfefferle
e21b8828c6 Add cors header 2024-06-07 19:04:53 +02:00
Jan Boddez
2b96c6efd2
Improve transformer (#731)
* Factory::get_transformer() may return a WP_Error instance

* Fix templates

* PHPDoc

* "Fix" conneg (for posts, at least)

* (Hopefully) fix conneg for comments, too

* Ugly, but works?

* Fix outboxes, collections

* Clean up a bit

* Use Factory

* Remove outdated `use`

* Use Transformer\Factory instead of Transformer\Post

* "Fix" _deprecated_function() call

* Remove superfluous transformer check

* Remove transformer check

* Call Transformer::get_transformer() only once per request

* PHPDoc

* this should be fine

a failing transformer is very unlikely because there are a lot of checks before `is_singular` or `is_comment` is valid.

* no longer used

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2024-05-16 15:14:31 +02:00
Matthias Pfefferle
f0c52580ff
Improve AUTHORIZED_FETCH (#728)
* simplify code

* show limited profile informations

* exclude application user

* use actor instead of user

* change JS

* use Application instead of Application_User

* re-add use

* add summary

* Improves comment intent

* remove limited actor json in favour of the application user

---------

Co-authored-by: Django Doucet <mediaformat.ux@gmail.com>
2024-05-03 08:54:06 +02:00
André Menrath
c67ef1b658
fix outbox collection for blog and application user (#724) 2024-04-10 08:36:51 +02:00
Matthias Pfefferle
2f66566f58 improve remote reply handling
see #720
2024-04-09 13:18:49 +02:00
Matthias Pfefferle
be3f754a25
mask version number (#719) 2024-04-05 15:49:38 -05:00
Matthias Pfefferle
85aa63e9f2 fix counter for system users 2024-03-26 15:26:26 +01:00
Matthias Pfefferle
7ca9c2bbfa fix #714 2024-03-26 15:22:21 +01:00
Matthias Pfefferle
5988736b14
Add/remote reply (#689) 2024-02-22 16:32:16 +01:00
Matthias Pfefferle
48feabe39e
Improve post-type support (#675)
* Improve post-type support

* Remove `page` from default types (fix #665)
* Add description to settings (fix #673)

* fix tests
2024-01-25 15:51:21 +01:00
André Menrath
174262d22c
Add/event objects (#629)
* remove redundant property definitions

* Add redused context for actors.

* Add classes to construct Moblizon compatible events

* Bind the context to the activitypub object
- change the propertyname  which stores the json-ld context from context to _context, because context is already reserved in the ActivityStreams vocabulary.
- cleanup currently unused code

* fix phpcs

* Remove PostalAddress object: it's enough (at least atm) to directly write the array in transformers.

* Remove _context property from ActivityPub objects in favour of getter function get_json_ld_context()

* fix unit tests: ActivityPub Activity objects have a custom getter for the JsonLD context

* fix phpcs

* fix unit-tests to also support php5.6

* fix phpcs

* add param include_json_ld_context to to_array function
This allows to not set the @context in the resulting array.

* propagate the param include_json_ld_context to nested calls of to_array.

* fix phpcs

* Nested AcitivityPub objects: never build context in inner items in to_array function

* fix: param of set_address may also be an array

* fix typo in comment

* always prefix json-ld context with json-ld and move event class to sub-namespace

* fix usage of reserved object keyword
seems it should not be used as a namespace either

* Merge commit 'b2271cda6b857f879e0abd4f3c6683642d725267' into add/event-objects

* Fix calling non-static function as static

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>

* Partly fix Json-LD contexts in collections

* Update includes/activity/class-base-object.php

* this is implicit

We already set the correct user with `$transformer->change_wp_user_id( $user_id );` so the Actor will be generated properly. We can change the behaviour, but we should not use both.

* this change prevents the Activity to re-use Object vars

this should stay as is, because it pre-fills the Activity with data (for example cc and to) and it will no longer be done with your change.

It is on purpose that it first sets the object and then replaces it with the URI.

See: https://github.com/Automattic/wordpress-activitypub/blob/master/includes/activity/class-activity.php#L195

* add `$include_json_ld_context` support to `to_json`

* disable some more contexts

* remove whitespace

* Add php-comment for 7ed17c042a

* Fix JSON-LD context for ActivityPub objects: child classes may override it.

* coding standards

* call folder/namespace `Extended_Object`

 to be consistent with folder names in singular

* fix: unnessesary nesting of extended-objects

* remove license

I hope this is fine, to have the complete plugin under the MIT @Menrath ?!?

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2024-01-18 16:35:52 +01:00
Matthias Pfefferle
2c107eec62
Use FEP-2c59 for WebFinger reference (#636) 2024-01-08 20:01:16 +01:00
Matthias Pfefferle
a8078ce72b
Shared Inbox (#617)
* init shared inbox

* try to get user id from activity

* some code formatting

* disable ACTIVITYPUB_SHARED_INBOX_FEATURE

* done!

* do not use the inbox-user at all

* fix user check!

* fix user check!
2023-12-22 17:45:27 +01:00
Matthias Pfefferle
b744dc551d
Comment Federation (#550)
* Comments 1

* Delete FUNDING.yml

* Add basic BuddyPress support

fix #122

thanks and props @skysarwer

* change URL to `bp_core_get_user_domain`

* fix "Follow" issue

fix #133

* fix #135

* version bump

* Create phpunit.yml

* Update composer.json

* Update composer.json

* Update phpunit.yml

* Update composer.json

* Create phpcs.yml

* Update phpcs.xml

* Update composer.json

* phpcs fixes

* fix typo

* Comments update

* webfinger_extract remove extra param

* coding standards

* Replies Collection, settings, other fixes

* Create stale.yml

* move stale file

* code standards cleanup

* Migrate / Update script

* bugfix

* add settings link to plugin page

* fix code standards

* fix cs

* fix PHPCS

* PHPCS fixes

* change background image for wp.org

* fix docker

* fix webfinger for email identifiers

fix #152

* version bump

* update composer file to fix unit testing

* allow plugins

* fix dependencies

* Migrate tools

* code cleanup

* regression fix

* Fix announce, clarified language

* update included filename

* code cleanup

* Improve migration UX

* Add comments view, warnings to migrate page

* style fix

* more style fixes

* Fix send_delete_activity

* replace ap_comment_id to reuse  replytocom var

* Comments class missing attributes

* Post class fix attributes

* move js file to assets/js

* Separate file for Comment processing hooks

* fix file path

* associate comments to back compat post

* Fix js assets enqueue

* change regex matching potential hashtags

Matches any string starting with '#' and consisting of any number and combination of [A-Za-z0-9_] that is directly followed by whitespace or punctuation. Groups everything after '#' for access in functions using this regex.

This fixes #183 (incomplete links on hashtags containing special characters) by not matching these at all.

* also detect hashtags at the start of a paragraph

* restrict html tags after which to detect a hashtag

Hashtags should not be detected after just any html tag - for example not after an opening a or div. To still allow detection at the start of a line, allow specifically p and br to directly precede a hashtag.

* fix pagination

* Add Custom Post Type support to outbox API

* remove comment_type

* fix comparison

* remove trailing spaces

* fix phpcs issues

* fix phpcs issues

* run phpcs also on pull_requests

* fix phpcs issues

* support threaded comments from ActivityPub

* refactor support for threaded comments from ActivityPub

* remove debugging log line

* add first unit tests for class inbox

* fix code smells

* make filter function static

* attempt to resolve backwards compatibility issues

* update js to new file

* delete old js

* Remove migrate code

* update post meta canonical

* remove type and mention meta from comment filters

* extract mentions from comment_content

* phpcbf

* remove extra curly bracket

* Remove migrate code

* remove version_check()

* Update enqueue scripts

* Remove remote comments from preprocessing

* Reply to comments from Dashboard

* rename function, inserts users into reply text

* Update dispatch comments

* update comment model

* fix comment model replies property

* fix preprocess_comment cap check

* Add webfinger filter to comments

* Add comment edit datetime

* cleanup

* fix var name

* cleanup

* phpcbf

* better actual translation support

* Separate comment reply script

* migrate dispatch, migrate comment model to transform

* ignore WP_Comment type for now

* Adds new helpers for resolving inReplyTo url

* Update activitypub_send_comment_activity to include type

* remove redundant id check

* reinclude user_id in saved ap_object meta

* update post field meta

* Fix comment updated datetime

* front-end reply inserts @mentions

* enqueue reply script on front end

* use const instead of dirname

* some simplifications

* move some functions

* fixes

* some more fixes

* fix namespace

* fix unittests

* fix testcase

* fixed typo

* fix tests

* fix tests

* fix PHPCS

* move functions to transformer class

* fix warnings

* Link remote comments on frontend

* Link to comment source as row action

* Init Comments class

* remove dead dispatch action

* re-add extract mentions filter

* Restore and tweak Comment transform

* Schedule comments activities for non-admin users

* lint

* remove context property

* rename get_id method to generate_id

* fix locale

* move functions

* PHPDoc

* this is never used

* remove some edit methods

* remove replies for now

* remove JS calls

* remove reply_recipients

* never used

* remove other query-vars

* otherwise to_json would not work properly

* small changes

* use `c` for comment IDs

* remove comments.php for now

maybe re-add it later

* wp_insert_post is an action

* also parse comment_text

* remove duplicate functions

* add Base transformer

* remove invalid test

* update to new query var

* update dispatcher to support comments and posts

* fix transition

* remove unused functions for now

* schedule_comment_activity seems to ignore create and update

* fix wrong use of functions!

* not every platforms sends an URL

* check source-id first

* remove hashtags for now

* fallback to ID

* fix typo

* move to_activity to Base class

* remove unused function

* add support for announce and like

* also ping inboxes of other commenters in the thread

* restructure WebFinger class

* some small improvements

* simplified to_object class

props @Menrath for the feedback and the idea!

* fix unit tests

* make transformer filterable

/cc @Menrath

* use transformer factory, so that transformer can be overwritten

* phpcs fixes

* fix attachments

* fix comment transformer

* remove comments for now

* update readme/changelog

* simplify and unify json_encodes

---------

Co-authored-by: Django Doucet <mediaformat.ux@gmail.com>
Co-authored-by: Andreas <andreas@bocops.de>
Co-authored-by: Eana Hufwe <eana@1a23.com>
Co-authored-by: Matthew Exon <git.mexon@spamgourmet.com>
Co-authored-by: Django Doucet <django.doucet@webdevstudios.com>
2023-12-22 10:12:26 +01:00
André Menrath
45e6ace890
Add nodeinfo metadata (#618)
* add nodeinfo metadata
nodeName, nodeDescription and nodeIcon

* Fix CS: double space typo
2023-12-21 16:05:32 +01:00
Matthias Pfefferle
f4cab6647d fix application user 2023-12-21 10:10:55 +01:00
Matthias Pfefferle
6f1a9a1f7f
added FEP-2677 (#613)
* added FEP-2677

This PR enables [FEP-2677: Identifying the Application Actor](https://codeberg.org/fediverse/fep/src/branch/main/fep/2677/fep-2677.md)

@Menrath I needed a small task for in between ;)

* update changelog
2023-12-21 10:06:37 +01:00
Matthias Pfefferle
39c9288987
Improve/webfinger (#616)
* Fix some WebFinger issues

* update changelog
2023-12-21 10:04:15 +01:00
Matthias Pfefferle
431c4a2676
WebFinger: Add support for URLs (#594)
* add support for URLs

* phpcs

* simplify vars
2023-12-11 10:28:41 +01:00
Matthias Pfefferle
e5fe4f20b7
some phpcs fixes (#590)
* some phpcs fixes

* add default $hashalg
2023-12-07 12:30:44 +01:00
Matthias Pfefferle
93b2f1ee7d
Normalize attributes that can have mixed value types (#586)
* fix #571

* support empty values

* fix phpcs issues

* test for `null`

* use `object_to_uri`  on followers list
2023-12-05 18:59:00 +01:00
Matthias Pfefferle
6e7f82bf42
Activity-Type based handlers (#551)
* init

* save source id

* fix delete and add improve undo

* test new functions

* add support for threaded comments

* some formatting

* check if URL is no longer available

...and returns either status 410 or 404.

* improve delete handler

* improve update handler

* `object` and `actor` are already required by the inbox endpoint

* fix typo

* simplify queries

* cosmetics

* fix unit tests

* schedule delete comments of deleted actor (#575)

* schedule delete comments of deleted actor

* phpcs

---------

Co-authored-by: Django Doucet <django.doucet@webdevstudios.com>

* move `get_comments_by_actor` to interactions collection

* consistent wording

* implement Tombstone

* fix follow issue

* fix inbox-create

* added missing namespace

* check if field is set

* Fix namespacing issue

* update profile and update interaction

* fields are already validated by inbox

* optimize avatar handling

---------

Co-authored-by: Django <mediaformat.ux@gmail.com>
Co-authored-by: Django Doucet <django.doucet@webdevstudios.com>
2023-11-30 11:43:48 +01:00
Matthias Pfefferle
1f5ef3ea2c Add Group Identifier to WebFinger endpoint 2023-11-27 13:51:30 +01:00
Matthias Pfefferle
ba44ac701b remove var_dump 2023-11-21 15:05:47 +01:00
Matthias Pfefferle
1af821621b check if ID is set
fallback to URL
2023-11-21 15:05:12 +01:00
Jan Boddez
efd98acd0b
Fix #493 (#497)
* Fix #493

* Fix parenthesis

* Allow `p` and `br` tags only for AP comments

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2023-11-13 10:19:35 +01:00
Matthias Pfefferle
6810884c52
have a filter to defer signature verification (#435) 2023-11-11 06:00:20 +01:00
Matthias Pfefferle
26d0d357c2
Add monthly active users (#530)
* Add monthly active users for better stats on FediDB

* use more optimized query

thanks @mattwiebe

* use transients, improve logic

---------

Co-authored-by: Matt Wiebe <wiebe@automattic.com>
2023-11-07 10:27:20 +01:00
Matt Wiebe
53adfe6b80
PHP 8.1 compatibility (#533)
* PHP 8.1 compatibility

* Update compat.php

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2023-10-25 08:44:04 +02:00
Matthias Pfefferle
8078512b8c small improvements 2023-10-24 14:54:03 +02:00
Matthias Pfefferle
e91334e4d7
fix following endpoint (#531)
* fix following endpoint

* version bump
2023-10-24 12:45:46 +02:00
Matthias Pfefferle
b946ef3de1
more consistent use of response content type (#529)
* more consistent use of response content type

* update readme

* fix typo
2023-10-23 14:57:58 +02:00
Matthias Pfefferle
0ab8df539e simplify check 2023-10-23 08:28:30 +02:00
Matthias Pfefferle
a40bd8408a
Various improvements (#527)
* remove unused code

* check if `$data['object']` is a sting

* do not index application user

* this fixes GoToSocial errors

* do not cache errors

* re-added the fragment

See https://github.com/superseriousbusiness/gotosocial/issues/2280

* Fix coding standards

* do not verify signature on head request
2023-10-21 11:23:05 +02:00
Matthias Pfefferle
2ef72a0364 API changes 2023-10-12 11:00:58 +02:00
Matthias Pfefferle
fd6cb84ba3 Fix compatibility with WebFinger and NodeInfo plugin 2023-10-11 11:09:37 +02:00
Matt Wiebe
9907585570
Plugin loading refactor (#485)
* Plugin loading refactor
* changed load order for REST endpoints

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2023-10-04 11:15:53 -05:00
Matthias Pfefferle
0d635d5dd1
More Group meta-data to play nicely with existing platforms (#441)
* more group friendly settings

* change http code

* Fix Actor-Type

* fix check if value is set

* only ignore null

* better posting_restricted_to_mods handling

* remove user namespace from moderators endpoint

thanks for the feedback @mattwiebe
2023-09-22 09:38:59 +02:00
Matthias Pfefferle
8dcbe0c6fd
fix Secops issues (#411) 2023-09-05 21:03:25 +02:00
Matthias Pfefferle
2705172b77
Fix some signature and application user issues (#410)
* Fix some signature and application user issues

* it seems that firefish needs at least an inbox also for application users

* prepare domain change

* use https

* fix PHPDoc

* remove image check

---------

Co-authored-by: Matt Wiebe <wiebe@automattic.com>
2023-09-01 18:32:56 +02:00
Matt Wiebe
9e73081668
deactivate the akismet nonce when processing our comments (#391) 2023-08-16 10:12:31 -05:00
Matthias Pfefferle
14b91cf760
remote-follow endpoint (#392)
Adds an endpoint at `users/$user_id/follow-me` to return the follow template for a remote user, to enable following them more easily.
2023-08-11 17:41:34 -05:00
Matthias Pfefferle
69ba1c87e1 fix sticky posts endpoint 2023-08-11 11:16:06 +02:00