Commit Graph

20858 Commits

Author SHA1 Message Date
Rostislav Wolny
25aefb9142 Display MTA error message also for subscribers limit reached error
This is a new operation error type added on the shop.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
77e64a7c57 Return plan limit data also for underprivileged keys
When a key is underprivileged it is still considered valid and
we can use the state data about limits.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
080b6a57ef Add MailPoet.hasValidMSSKey
I added the property so that we can check all combinations.
Currently it is not used but was added for completeness.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
600c83943c Change login of MailPoet.hasValidApiKey key JS property
The API key that is underprivileged for MSS and Premium
is still considered as valid because the API can still authenticate the key
and the key can be used reporting subscriber stats etc.

I've check places where we use the property and in all cases we use
to distinguish if the plugin uses a subscription plan (free or paid) or no plan.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
6aaa56466e Display subscribers limit reached also when API reports restricted access
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
a21530a78d Add variant of email volume reached message for the case we don't know limit
In case the user uses an API key that has restricted access to MSS
due email volume limit on a fresh site. The site has no cached data about
the limits. We need a variant of the message also for the case.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
aa63f9e0c4 Hide MTA log error for email volume limit in case we show global error
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
b82ff65690 Replace separately places notices by component that groups them
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
9bc8b8095d Add component for displaying MSS access/limits error notices
We don't want to display all notifications at the same time so
this component holds the logic for displaying the proper ones.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
20a8afa2f1 Fix logic for detecting emails volume reached error
The values we have in key state might be missing or outdated.
We need to check also if the key check on MSS returned error
about access being restricted due email volume limit.

[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
15aeea834f Handle error message for exceeded email limit when limit is not known
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
469b9bf85f Remove unnecessary premium key refresh when volume limit error happens
The limit is stored in and read from MSS key state and now we preserve
state data even when the key becomes underprivileged.
We don't need to refresh anything and also the checking underprivileged key
would return 403 and no data about limits.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
48f1034180 Read email volume limit from and send emails count from MSS key data
Currently the starter plan has no access to premium so the plugin is
not able to fetch email volume limit using premium key endpoint.
Also the data are related to sending so it makes more sense to read those
from MSS key state.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
db467d8616 Add handling of subscriber limit error to MailPoet error mapper
When the shop blocked access for an API key due subscriber limit it used
to set the error as "Insufficient privileges," and that was in the plugin
interpreted same as "Subscribers limit reached".
The SHOP-1228 changes the error message will be set to "Subscribers limit reached".
This commit updates the error mapper to be able to process the new error message.
It also keeps the old approach for previously blocked keys.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
eb06b6d01e Preserve key state data when checking key and get invalid result
The state data contain info about plan limits etc. we don't want
to lose the info when key becomes underprivileged so that we can
show the limits in notifications.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
cd5a023b35 Move onSettingsChange from Bridge service to SettingsChangeHandler
Bridge is a low level service that processes requests and responses to/from Bridge API.
This change is needed so that we can remove dependency on MailPoet\Util\License\Features\Subscribers
service from the Bridge. The dependecy is a higher level service and may easily cause a circular dependency issue.

The SettingsChangeHandler is service for handling side effects
when saving settings. This feels as a better place to put the functionality.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
ab19ef92d5 Use subscriber count reporter in cron for reporting stats
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
d9bec53efa Introduce new service for reporting subscriber stats
Bridge is a low level service that processes requests and responses to/from Bridge API.
This change is needed so that we can remove dependency on MailPoet\Util\License\Features\Subscribers
service from the Bridge. The dependecy is a higher level service and may easily cause a circular dependency issue.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
4995ed93f0 Refactor invalidation of MSS key to non static method
This is the olny staically called method from the service. In this commit I refactored it to non-static so that it works properly with injected services.
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
638c7005d9 Refactor storing MSS and Premium key and state to use common private method
[MAILPOET-5191]
2023-05-10 13:05:37 +02:00
Rostislav Wolny
ae430480ad Prevent interaction with the checkout opt-in checkbox element
[MAILPOET-5276]
2023-05-09 15:45:22 +02:00
Rostislav Wolny
f8b6f77762 Update visual appearance of opt-in block in checkout block
[MAILPOET-5276]
2023-05-09 15:45:22 +02:00
Veljko
4bda0770e1 Update k6 and switch to CWV
[MAILPOET-5287]
2023-05-09 14:46:03 +02:00
John Oleksowicz
f75173dcd5 Add "subscribed via form" dynamic filter
MAILPOET-5005
2023-05-09 13:10:08 +02:00
Oluwaseun Olorunsola
1923ca9ae3 Release 4.15.0 2023-05-09 12:32:14 +02:00
Rodrigo Primo
9ab62ea2e1 Change the frequency of the Beamer worker to once every two weeks
[MAILPOET-5275]
2023-05-08 14:39:52 +02:00
Jan Jakes
4ad01230f8 Improve timezone property and function naming
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
08d2039ce3 Render datetime values
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
e81a8fca6a Load @wordpress/date settings and locale data for date picker
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
5800897cc0 Install and expose @wordpress/date
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
3d78cfaef3 Expose date/time components and dropdown
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
2a38e639db Implement datetime filter
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
607e193c0d Add datetime field to subscriber subject
[MAILPOET-5000]
2023-05-08 13:58:31 +02:00
Jan Jakes
a3bf9122c6 Add filter group operator switching UI with upsell modal
[MAILPOET-5218]
2023-05-04 14:34:11 +02:00
Jan Jakes
b45e105cb4 Evaluate global filter operator
[MAILPOET-5218]
2023-05-04 14:34:11 +02:00
Jan Jakes
c40cb47928 Evaluate filter group operators (and/or)
[MAILPOET-5218]
2023-05-04 14:34:11 +02:00
Rodrigo Primo
e0317c5dbf Bump WP require at least to 6.0 and tested up to 6.2
[MAILPOET-5075]
2023-05-03 16:34:35 +02:00
Rostislav Wolny
5fa1ba823b When deleting old logs Delete oldest logs first
[MAILPOET-5071]
2023-05-03 13:34:33 +02:00
Rostislav Wolny
6f70cd1651 Limit rows deleted from mailpoet_logs in on run of purge routine
The probability of the routine to run is 5% so it should run approximately 5 times
per 100 writes. So the limit 1000 should be pretty safe to prevent the table from bloating.
[MAILPOET-5071]
2023-05-03 13:34:33 +02:00
Brezo Cordero
bcee2abb2c Improve translations error handling
Use wp_json_encode in case files contain invalid UTF-8 characters and catch WP_Errors when fetching the translations.

[MAILPOET-5253]
2023-05-03 12:46:07 +02:00
Jan Lysý
c711eac7f4 Update custom fields on confirmation when are stored in unconfirmed data
[MAILPOET-5246]
2023-05-03 11:31:24 +02:00
Jan Lysý
150042f670 Disable overriding custom fields on repeated subscribing
[MAILPOET-5246]
2023-05-03 11:31:24 +02:00
Jan Lysý
2ef78b1bba Add getter for specific subscriberCustomField entity in relation
[MAILPOET-5246]
2023-05-03 11:31:24 +02:00
Jan Lysý
41abed3b15 Add custom field to subscriber's relation when it is created
[MAILPOET-5246]
2023-05-03 11:31:24 +02:00
Rodrigo Primo
9ab4fd2bdf Escape data sent from Twig to JS variables
This commit changes the way that we are passing data from Twig to JS
variables. Before we were using the raw value of the variable which
could be insecure depending on the source of the variable. Malicious
code could be injected in the variable that would result in JS code
being executed in the browser.

Now we are escaping the value of the variable and then parsing it with
JSON.parse(). This should ensure that whatever is the content of the
Twig variable, it is never possible to inject code that is executed by
the browser.

[MAILPOET-5238]
2023-05-03 10:48:40 +02:00
Rodrigo Primo
33caa0c539 Add a new Twig filter that uses wp_kses() and use it instead of raw
Before this commit, whenever we needed to output HTML from a function
call in a Twig template, we would use the raw filter that allows any
kind of HTML to be outputted.

This commit adds a new filter called wpKses that internally calls
wp_kses(). We can use this filter instead of raw, this way we can define
the list of allowed HTML and the output becomes more secure.

This commit also replaces all the instances where we were using raw.

[MAILPOET-5238]
2023-05-03 10:48:40 +02:00
Rodrigo Primo
4912e28389 Remove unnecessary call to Twig raw filter
Since here we are just outputing a URL to a HTML attribute, raw is not
needed and we can let Twig auto escaping work.

[MAILPOET-5238]
2023-05-03 10:48:40 +02:00
Rodrigo Primo
dad6cb5795 Remove use of the Twig raw filter
In this particular template, using raw was not necessary as the HTML
markup encapsulated the full translatable string. So I removed the call
to raw, and added the HTML markup directly to the template.

[MAILPOET-5238]
2023-05-03 10:48:40 +02:00
Rodrigo Primo
fac3d77407 Remove unused view index.html
I found this file as part of the ticket to investigate Twig templates in
the context of the security scan ([MAILPOET-5238]) as it use the `raw`
filter. It seems this file is not used anymore, so instead of fixing the
use of `raw`, I'm removing it.

As far as I can check, we stopped using this view back in 2016, when
this commit f8efb3934b replaced the homepage
with the newsletter page.
2023-05-03 10:48:40 +02:00
John Oleksowicz
c411186a98 Add migration to fix problem on existing sites
MAILPOET-5261
2023-05-03 10:21:13 +02:00