-
Notifications
You must be signed in to change notification settings - Fork 82
Add Perfecty Push integration for web push notifications #2216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
- Add new integration class for Perfecty Push plugin compatibility - Hook into ActivityPub events (likes, announces, creates, follows) via activitypub_handled_* actions - Add per-user and blog actor notification settings with UI in profile pages - Include actor profile images with mp.jpg fallback for users without avatars - Support individual notification type toggles (likes, reposts, comments, followers) - Integrate settings into existing ActivityPub profile sections alongside email notifications
Replaces get_actor with fetch_by_uri for actor retrieval and decodes comment excerpts for notifications. Removes unused helper methods for actor name and image, and ensures the notification includes a direct comment link. Also updates integration file path resolution and streamlines notification sending.
Set the priority to 11 for user and blog settings registration hooks to ensure they run after ActivityPub settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Perfecty Push integration to enable web push notifications for ActivityPub events. It creates a comprehensive notification system that triggers push notifications when fediverse users interact with ActivityPub content.
- Adds support for four notification types: likes, reposts/boosts, comments, and new followers
- Integrates individual notification settings for both user profiles and blog actor profiles
- Includes fallback actor images and error handling for robust notification delivery
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
integration/load.php | Conditionally loads Perfecty Push integration when plugin is active |
integration/class-perfecty-push.php | Complete integration class handling notifications, settings, and UI rendering |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
error_log( 'ActivityPub Perfecty Push notification failed: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using error_log() directly is discouraged in WordPress. Consider using wp_die() for fatal errors or a proper logging mechanism that respects WordPress debugging settings.
error_log( 'ActivityPub Perfecty Push notification failed: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | |
} | |
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { | |
error_log( 'ActivityPub Perfecty Push notification failed: ' . $e->getMessage() ); | |
} |
Copilot uses AI. Check for mistakes.
Removes the conditional check for the 'blog-profile' tab when registering the push notifications settings field, ensuring it is always added to the blog settings.
…m/Automattic/wordpress-activitypub into feature/perfecty-push-integration
Why this plugin? |
Honestly, I didn't even look much. https://github.com/web-push-libs/web-push-php was suggested as a popular PHP library and it mentions Perfecty Push Notifications as a plugin that integrates it. Now, after your prompt and after installing and testing about 10 other Web Push plugins in the repo, I'd add that it's the only one that just works out of the box, without having to create an account, an API key, or buy a plan. |
Some learnings from working on this PR:
|
At least the notification class unifies the actions and it's params. The other actions are very inconsistend and depending on the implementer and the needs of the feature. |
/** | ||
* Render the user notification settings field. | ||
*/ | ||
public static function render_user_notification_field() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid this, with the initial version of the notification settings an the table (I hope you remember)! I think this is not a good UI and we should avoid adding settings through extensions.
The Notification class was meant to be a nice hook for dependency injection. WordPress does not provide notifications and because this might be a need, the idea was to have a unified way to trigger notifications and an even easier way to subscribe to them. |
$default_enabled = array( 'like', 'announce', 'create', 'follow' ); | ||
|
||
// Check user-specific settings first. | ||
$user_settings = \get_user_meta( $user_id, 'activitypub_perfecty_push_notifications', true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notification settings should be generic and plugin independent. It doesn't matter what plugin you use, the settings should be the same.
I previously created a Core ticket regarding web push notifications.
|
I could have sworn there was a forum post asking for Web Push support. Well, I can't find it anymore.
Proposed changes:
/integration/class-perfecty-push.php
activitypub_handled_*
events to send web push notificationsOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Add Perfecty Push integration for web push notifications on ActivityPub events