perfectyorg / perfecty-push-wp Goto Github PK
View Code? Open in Web Editor NEWWordPress plugin for self-hosted Web Push Notifications ⚡️
Home Page: https://perfecty.org
License: GNU General Public License v2.0
WordPress plugin for self-hosted Web Push Notifications ⚡️
Home Page: https://perfecty.org
License: GNU General Public License v2.0
Instead of using the user friendly permalinks for REST Routes, the plugin should be independent and use instead: https://developer.wordpress.org/reference/functions/get_rest_url/
Reference: https://wordpress.stackexchange.com/questions/273144/can-i-use-rest-api-on-plain-permalink-format
It would be nice to be able to search through records in user table (UUID, IP address) at /wp-admin/admin.php?page=perfecty-push-users
One enhancement could be to give users the possibility to chose between notifications categories they want to subscribe
Related to https://wordpress.org/support/topic/anonymize-ip-7/
You know in some cases for collect the user’s IP you need a permission and besides that, we don’t want to do it. (Collect the user’s IP for privacy reasons).
We could maybe add a checkbox that enables/disables the collection of the IP address.
Related to https://wordpress.org/support/topic/need-more-options-7/
The plugin is great with basic features. But need important features like segmentation and user role capture (so that I can send notifications to paid users only), etc.
If I delete all the users from Perfectly Push > Users, it should delete all of them and users should be asked to allow notifications on their next visit, right? But is not happening. Deleting all users only deletes them from the admin interface. When visiting the website (cache cleared), deleted users are not prompted to allow notifications and if you click on the bottom bell icon, the checkbox is already checked. Unchecking that box returns an error "Could not change the preference, try again" (btw, the plugin should allow us to change this text from the settings because not everybody speaks English).
Hi,
I'm not sure if I need to do something extra?
Here's the latest results:
2021-03-02 21:56:03
Status:
completed
Stats:
Total: 2
Succeeded: 2
Failed: 0
Execution details:
Finished
Batch size: 30
Duration: 00h:01m:11s
Endpoint is registered and active. But I see no notifications
Relates to https://wordpress.org/support/topic/does-not-support-arabic-language-can-we-hide-the-floating-bell/
Make it configurable to hide the subscription bell after a user has subscribed. This is only for already subscribed users. For users that haven't been subscribed yet, the bell will always appear.
Please be so kind to add action in the code when sending notification (i.e. when "Send notification on publish" is checked and then post is updated) with payload as parameter.
This will allow sending notifications via other push provider supporting iOS and Android platforms, until Perfecty Push libs for such platforms are created.
To make the troubleshooting easier, we could add a displaying mechanism for Logs. For security reasons, the log folder needs to have a special name, needs an index.php file and a .htaccess file like: https://github.com/inpsyde/backwpup/blob/bdb72dd8d51076d7e11bf9ce52e0f94e1246ca33/inc/class-file.php#L184-L189
We need to consider log rotation also. We could either use a Logging library like Monolog or simply create a custom and lighter one to avoid potential collisions with conflicting composer versions from other plugins.
i"m facing a problem with firefox for android i don't get the subscribe pop up or the subscribe bell at all but it works on the desktop and chrome for android
Hi, just installed the plugin on a new wp instance, where the database is set with utf8_general_ci as charset collate.
After configuring the plugin, I tried to subscribe notification, but I received from the front js the following message: "Could not change the preference, try again" (in English, but this is my fault, next days I will post a patch to translate messages in public/js/perfecty-push-public.js).
Then looking at apache error log, I have seen the error that is _"[...] perfecty_push_users' doesn't exist for query SELECT id,uuid,endpoint,key_auth,key_p256dh,remote_ip,is_active [...]".
So, perfecty_push users table is missing.
I checked via phpmyadmin and there is no perfecty_push_users table in my db.
So:
I tried to manually execute the query in lib/class-perfecty-push-lib-db.php to create the table and mysql answered:
Query SQL:
CREATE TABLE IF NOT EXISTS [my_prefix]_perfecty_push_users (
id int(11) NOT NULL AUTO_INCREMENT,
uuid char(36) NOT NULL,
remote_ip varchar(46) DEFAULT '',
endpoint varchar(500) NOT NULL UNIQUE,
key_auth varchar(100) NOT NULL UNIQUE,
key_p256dh varchar(100) NOT NULL UNIQUE,
is_active tinyint(1) DEFAULT 1 NOT NULL,
disabled tinyint(1) DEFAULT 0 NOT NULL,
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY users_uuid_uk (uuid),
UNIQUE KEY users_endpoint_uk (endpoint)
)
Messaggio di MySQL: Documentazione
#1071 - Specified key was too long; max key length is 1000 bytes
MySQL server is 5.6.47 version and I am using MyISAM tables, so the problem is in using endpoint for index because MySQL 5.6 has a limit of 1000 bytes of index and endpoint varchar(500) uses 500 x 4 = 2000 bytes in utf8.
In this topic, I found useful info about the issue: https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes
Sending 10.000 notifications takes 20 minutes on DigitalOcean Basic Droplet / 2 GB RAM / 1 Shared vCPU. That's extremely slow.
The goal is to send 10.000 notifications in 1-2 minutes without significantly raising the CPU load.
https://github.com/web-push-libs/web-push-php#how-do-i-scale mentions couple of things to do:
Other ideas:
Another thing to note is that WP Crons are activated usually per page visit, so if the WP Cron that executes a single batch has finished, there’s a dead spot in which we lose some seconds. For 10.000 notifications in batches of 100, it’s 100 cycles, it means that if we wait 1 second between cycle, we lose 1,6 min, for 2 seconds we lose 3.3 min, etc… As we said, there’s definitively room for improvement, e.g. one alternative would be to have a script with no execution limit and we can send everything in one single cycle.
Deleting the plugin and reinstalling it keeps the same settings, texts, vapid key, everything.
Shouldn't all these be deleted when the plugin is deleted?
Related to: https://wordpress.org/support/topic/unable-to-get-it-work-2/
This has been addressed before but looks like a regression problem.
Apparently the plugin needs to review its integration with AMP plugins, this one in particular: https://wordpress.org/plugins/amp/
Related to https://wordpress.org/support/topic/a-strange-error/
Make this message localizable:
“The tables for Perfecty Push are missing, check the error logs and reactivate the plugin again.”
As reported here, it's conflicting with the Make Tables Responsive plugin:
https://wordpress.org/support/topic/problems-with-color-picker/
Upgrade url-parse to avoid CVE-2021-27515 and some styling fixes
Related:
https://wordpress.org/support/topic/perfecty-push-notifications-widgets/
https://github.com/rwngallego/perfecty-push-js-sdk/security/dependabot/package-lock.json/url-parse/open
As described in the Passive approach here, we would like to have a dedicated section where the users can opt-in for Push Notifications. It will not open the pop up to the new visitors but instead they will be able to subscribe on demand.
It would be nice to be able to remove "Send featured image or first image found in content" and "Custom title (default: website name)" fields from the meta box in Settings.
Related to issue: https://wordpress.org/support/topic/can-i-use-this-plugin-for-sending-custom-personal-push-messages/
Can I use this plugin for sending custom personal push messages? Do you have some PHP API or callback to send custom messages for only one subscribed user?
Some users have reported that even though the users can subscribe, no notifications are being sent. They get stale in a "Running" status and in the PHP error logs, we can notice something like:
Backend fatal error: PHP Fatal error: Uncaught Error: Call to undefined method GuzzleHttp\\Utils::chooseHandler() in wp-content/plugins/perfecty-push-notifications/vendor/guzzlehttp/guzzle/src/functions.php:61\nStack
Hi @rwngallego
This plugin is awesome! But what if I want to show alerts directly on all pages without using the bell?
I also looked at perfecty-push-js-sdk, but it looks like I need to change the Plugin after all, so please let me know.
Sorry for the text in translation.
Unable to register the service worker DOMException: Failed to execute 'subscribe' on 'PushManager': Subscription failed - no active Service Worker.
Please add "IP Address" column to user table wp-admin/admin.php?page=perfecty-push-users
It seems it was there previously, but for some reason it is missing now:
https://ps.w.org/perfecty-push-notifications/assets/screenshot-7.png?rev=2446200
This is important to identify test users and later add Country column in some new version.
What about creating a scheduler to send notifications starting at a certain date/time in the future?
Many users are reporting to me that the subscribe alert keeps showing even if they click on "nope", but only on MacOS (both chrome and safari).
If they try to subscribe the alert disappears but subscription doesn't work and they got an error.
Even if on the Dashboard and in the Notification section the notifications appear as sent successfully (Succedeed:4, Failed:0), there were no notifications received in the browsers of the subscribers.
The hosting provider said "it is also not possible to integrate ngx_http_dav_module with Runcloud Nginx. Because it may break the default Nginx configuration badly"
Any solution for this?
As in the title, may be usefull to add a parameter to URLs to monitor it on google analytics.
Relates to:
https://wordpress.org/support/topic/update-issue-with-the-plugin-progressive-wordpress/
There's a third party Service Worker in the root scope, when the registration is triggered, the Perfecty SDK detects it as a conflict but skips the Service Worker installation:
Starting Perfecty Push SDK
perfecty-push-sdk.min.js?ver=1.1.3:1 Drawing controls
perfecty-push-sdk.min.js?ver=1.1.3:1 Showing the bell and settings controls
perfecty-push-sdk.min.js?ver=1.1.3:1 The site has not permissions granted
perfecty-push-sdk.min.js?ver=1.1.3:1 Perfecty Push SDK was started
perfecty-push-sdk.min.js?ver=1.1.3:1 User is accepting the subscription
perfecty-push-sdk.min.js?ver=1.1.3:1 Requesting Notification permission
perfecty-push-sdk.min.js?ver=1.1.3:1 Notification permission
perfecty-push-sdk.min.js?ver=1.1.3:1 granted
perfecty-push-sdk.min.js?ver=1.1.3:1 User has granted permissions
perfecty-push-sdk.min.js?ver=1.1.3:1 Service Worker found
perfecty-push-sdk.min.js?ver=1.1.3:1 Registering user
perfecty-push-sdk.min.js?ver=1.1.3:1 Subscribing to Push Notifications
perfecty-push-sdk.min.js?ver=1.1.3:1 Sending user registration
perfecty-push-sdk.min.js?ver=1.1.3:1 Registering user in the server
perfecty-push-sdk.min.js?ver=1.1.3:1 The user was registered successfully
perfecty-push-sdk.min.js?ver=1.1.3:1 Hiding the bell and settings control
Hello, I just installed your WP plugin to test it out and looks like there's an issue with Cloudflare, the world's most used CDN.
The PUT http method is blocked so the subscription never gets to the server, the call to the endpoint returns a 405. error.
These are de response headers for the request:
allow: GET,POST,OPTIONS,HEAD,TRACE
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
cf-cache-status: DYNAMIC
cf-railgun: direct (starting new WAN connection)
cf-ray: 62dfbc72391fc769-AMS
cf-request-id: 08bfb41b660000c7697f875000000001
content-type: text/html; charset=iso-8859-1
date: Wed, 10 Mar 2021 21:46:30 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
nel: {"max_age":604800,"report_to":"cf-nel"}
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=%2BDRLA2DRPHKzBo7GJlzfpNTi6tKqH3zgBj9UBRPQS3Ah58knua7oGdcLVknT%2FsN4n0V3K0286e76F9y50EBgepk%2BVMNuZWv6FnLTMA%3D%3D"}],"group":"cf-nel","max_age":604800}
server: cloudflare
and this is the response got in browser from the API endpoint:
Do you think you could change the way the subscription is passed from browser to server, from PUT to POST?
Thanks!
Edit: found a better explanation here: https://gridpane.com/kb/making-nginx-accept-put-delete-and-patch-verbs/
Cloudflare uses NGINX server.
Instead of displaying prompt right away to the new visitor, would like to display it after X pageviews, to be less intrusive.
Using the following for OneSignal:
jQuery(document).ready(function($) {
window.OneSignal = window.OneSignal || [];
var numVisitsTrigger = 3; /* Number of page visits before prompting user */
window.OneSignal.push(function() {
var numVisits = new Number(localStorage['numVisitsTrigger'] || 0);
numVisits += 1;
localStorage['numVisitsTrigger'] = numVisits;
if (numVisits >= numVisitsTrigger) {
promptAndSubscribeUser();
}
});
function promptAndSubscribeUser() {
window.OneSignal.isPushNotificationsEnabled(function(isEnabled) {
if (!isEnabled) {
// Show Slide Prompt
window.OneSignal.showSlidedownPrompt();
}
});
}
});
As reported here https://wordpress.org/support/topic/select-icon-from-media-library/
When Appearance > Customize > Site Identity > Site Icon is empty, it would be nice to be able to select icon for notifications from Media Library.
In several themes this field is empty, because they are handling site icon on its own. Adding icon to Appearance > Customize > Site Identity > Site Icon creates some duplicate HTML code.
Related to https://wordpress.org/support/topic/jquery-usage-in-perfecty-push-notifications/
We need to remove any dependency to jquery. This was partially done with the introduction of the JS SDK, however we need to remove it completely from the public area.
Related to issue: https://wordpress.org/support/topic/integrating-with-pwa/
How do we handle conflicting service workers?
I have reviewed the code on GitHub and I believe we can edit the plugin service worker to include any other service works. The importStripts('exampleURL.com/js-serviceworker.js'); technique will merge service workers and allow them to work together.
sometimes the notification job fail and the status of the failed notification is :
scheduled
at 1970-01-01 00:00:00
this is the log from the admin panel :
2021-07-06 17:02:17 | INFO | Next ticker scheduled at: 2021-07-06 18:03:16
2021-07-06 17:01:30 | INFO | Cron check ticked
2021-07-06 16:59:51 | INFO | Next ticker scheduled at: 2021-07-06 18:00:51
2021-07-06 16:59:37 | INFO | Cron check ticked
2021-07-06 16:58:37 | INFO | Next ticker scheduled at: 2021-07-06 17:59:37
2021-07-06 16:58:29 | INFO | Cron check ticked
2021-07-06 16:57:24 | INFO | Next ticker scheduled at: 2021-07-06 17:58:24
2021-07-06 16:57:23 | INFO | Next ticker scheduled at: 2021-07-06 17:58:23
2021-07-06 16:57:20 | INFO | Cron check ticked
2021-07-06 16:56:21 | INFO | Scheduling a broadcast notification
2021-07-06 16:56:21 | DEBUG | Array ( [title] => MJB Tech Tips [body] => كشفت ASRock عن قائمة اللوحات الأم التي ستدعم ويندوز 11 [icon] => https://mjbtechtips.com/wp-content/uploads/2021/06/cropped-icone.png [image] => https://mjbtechtips.com/wp-content/uploads/2021/06/2021-06-25-image-23-j.webp [require_interaction] => 1 [extra] => Array ( [url_to_open] => https://mjbtechtips.com/2021/07/%d9%83%d8%b4%d9%81%d8%aa-asrock-%d8%b9%d9%86-%d9%82%d8%a7%d8%a6%d9%85%d8%a9-%d8%a7%d9%84%d9%84%d9%88%d8%ad%d8%a7%d8%aa-%d8%a7%d9%84%d8%a3%d9%85-%d8%a7%d9%84%d8%aa%d9%8a-%d8%b3%d8%aa%d8%af%d8%b9%d9%85/ ) )
2021-07-06 16:56:21 | INFO | Scheduling job id=61, result: 1
and this is from /var/log/php7.4-fpm.log
[06-Jul-2021 16:56:21] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
there was nothing on the /var/log/nginx/error.log related to this event
Please be so kind to add default value for "Send featured image or first image found in content" in Settings.
No logs are being recorded by default. Apparently we are not using the error_log()
driver when the custom logging is disabled.
/wp-content/plugins/perfecty-push-notifications/admin/js/perfecty-push-admin.js is using deprecated jQuery.fn.load()
Related to: https://wordpress.org/support/topic/delete-user-from-database-on-unsubscribe/
We need to remove the users that have opted out, instead of marking them as inactive in the DB. There's no gain in having them in the DB, as usually they will not receive any push messages, and the subscription could expire in between opting out/in again.
In the JS side, the SDK should not check the user registration from the server if the status is marked as inactive
in the LocalStorage.
As discussed at https://wordpress.org/support/topic/onesignal-6/
Isn’t it better to target specific workers such as OneSignalSDKWorker.js instead of removing all of them?
This is difficult because we would have to have a DB of the possible existing Push Providers (OneSignal is just one of tens of them).
To resolve "Don’t use it with PWA/AMP" issue when migrating from the other push provider, there should be a list of service workers that should be ignored, i.e. won't be automatically unregistered when "Remove conflicting workers" is enabled.
That we should explain webmasters in documentation how to find names of PWA/AMP service workers in browser console and put them in such list?
Notifications should not disappear after 10 seconds, but should be displayed on screen until user clicks it or closes it using Close button, just like OneSignal's notifications do.
Reported here: https://wordpress.org/support/topic/best-self-hosted-plugin-but-not-perfect/
CloudFlare and logging visitor IP addresses via in PHP
https://stackoverflow.com/questions/14985518/cloudflare-and-logging-visitor-ip-addresses-via-in-php
Similar to this using the updated IP ranges: https://github.com/piccaso/joomla-cf/blob/master/cf/cf.php
IP ranges: https://www.cloudflare.com/ips/
Make sure that the plugin warns if the wp-crons are disabled. Usually they're disabled like this: https://zeropointdevelopment.com/disabling-wp-cron-in-wordpress/#:~:text=To%20disable%20WP%2DCron%20in,up%20from%20your%20local%20machine.
If they're disabled, the plugin cannot execute the background jobs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.