mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Added webmentions emails flag (#16321)
fixes https://github.com/TryGhost/Team/issues/2599 Disables sending webmentions notification emails, and hides it behind a new flag instead.
This commit is contained in:
parent
c9fa1068a0
commit
f6bc3479f9
8 changed files with 72 additions and 23 deletions
|
@ -68,6 +68,7 @@ export default class FeatureService extends Service {
|
|||
@feature('suppressionList') suppressionList;
|
||||
@feature('emailStability') emailStability;
|
||||
@feature('webmentions') webmentions;
|
||||
@feature('webmentionEmails') webmentionEmails;
|
||||
@feature('outboundLinkTagging') outboundLinkTagging;
|
||||
@feature('emailErrors') emailErrors;
|
||||
@feature('milestoneEmails') milestoneEmails;
|
||||
|
|
|
@ -213,6 +213,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
<h4 class="gh-expandable-title">Webmention notification emails</h4>
|
||||
<p class="gh-expandable-description">
|
||||
Send a notification email to staff when a webmention is received.
|
||||
</p>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<GhFeatureFlag @flag="webmentionEmails" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gh-expandable-block">
|
||||
<div class="gh-expandable-header">
|
||||
<div>
|
||||
|
|
|
@ -265,26 +265,26 @@
|
|||
</div>
|
||||
</div>
|
||||
{{#if this.user.isAdmin}}
|
||||
{{#if (feature 'webmentions')}}
|
||||
<div class="user-setting-toggle">
|
||||
<div>
|
||||
<label for="user-email">New Mentions</label>
|
||||
<p>When you receive a new webmention</p>
|
||||
{{#if (and (feature 'webmentions') (feature 'webmentionEmails')) }}
|
||||
<div class="user-setting-toggle">
|
||||
<div>
|
||||
<label for="user-email">New Mentions</label>
|
||||
<p>When you receive a new webmention</p>
|
||||
</div>
|
||||
<div class="for-switch small">
|
||||
<label class="switch" for="mention-notifications" data-test-label="mention-notifications">
|
||||
<input
|
||||
id="mention-notifications"
|
||||
type="checkbox"
|
||||
checked={{this.user.mentionNotifications}}
|
||||
class="gh-input"
|
||||
{{on "change" this.toggleMentionNotifications}}
|
||||
data-test-checkbox="mention-notifications"
|
||||
>
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="for-switch small">
|
||||
<label class="switch" for="mention-notifications" data-test-label="mention-notifications">
|
||||
<input
|
||||
id="mention-notifications"
|
||||
type="checkbox"
|
||||
checked={{this.user.mentionNotifications}}
|
||||
class="gh-input"
|
||||
{{on "change" this.toggleMentionNotifications}}
|
||||
data-test-checkbox="mention-notifications"
|
||||
>
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if this.canToggleMemberAlerts}}
|
||||
<div class="user-setting-toggle">
|
||||
|
|
|
@ -81,6 +81,7 @@ describe('Acceptance: Staff', function () {
|
|||
enableMembers(this.server);
|
||||
enableStripe(this.server);
|
||||
enableLabsFlag(this.server, 'webmentions');
|
||||
enableLabsFlag(this.server, 'webmentionEmails');
|
||||
|
||||
admin = this.server.create('user', {email: 'admin@example.com', roles: [adminRole]});
|
||||
|
||||
|
@ -880,7 +881,7 @@ describe('Acceptance: Staff', function () {
|
|||
await click('[data-test-save-button]');
|
||||
|
||||
await visit(`/settings/staff/${admin.slug}`);
|
||||
|
||||
|
||||
expect(find('[data-test-checkbox="free-signup-notifications"]')).to.be.checked;
|
||||
expect(find('[data-test-checkbox="paid-started-notifications"]')).to.be.checked;
|
||||
expect(find('[data-test-checkbox="paid-canceled-notifications"]')).to.be.checked;
|
||||
|
|
|
@ -37,7 +37,8 @@ const ALPHA_FEATURES = [
|
|||
'beforeAfterCard',
|
||||
'lexicalEditor',
|
||||
'outboundLinkTagging',
|
||||
'websockets'
|
||||
'websockets',
|
||||
'webmentionEmails'
|
||||
];
|
||||
|
||||
module.exports.GA_KEYS = [...GA_FEATURES];
|
||||
|
|
|
@ -30,6 +30,7 @@ describe('Webmentions (receiving)', function () {
|
|||
await allSettled();
|
||||
mockManager.disableNetwork();
|
||||
mockManager.mockLabsEnabled('webmentions');
|
||||
mockManager.mockLabsEnabled('webmentionEmails');
|
||||
emailMockReceiver = mockManager.mockMail();
|
||||
});
|
||||
|
||||
|
@ -367,6 +368,35 @@ describe('Webmentions (receiving)', function () {
|
|||
emailMockReceiver.sentEmailCount(0);
|
||||
});
|
||||
|
||||
it('does not send notification with email flag disabled', async function () {
|
||||
mockManager.mockLabsDisabled('webmentionEmails');
|
||||
|
||||
const targetUrl = new URL('integrations/', urlUtils.getSiteUrl());
|
||||
const sourceUrl = new URL('http://testpage.com/external-article-123-email-test-2/');
|
||||
const html = `
|
||||
<html><head><title>Test Page</title><meta name="description" content="Test description"><meta name="author" content="John Doe"></head><body></body></html>
|
||||
`;
|
||||
|
||||
nock(targetUrl.origin)
|
||||
.head(targetUrl.pathname)
|
||||
.reply(200);
|
||||
|
||||
nock(sourceUrl.origin)
|
||||
.get(sourceUrl.pathname)
|
||||
.reply(200, html, {'Content-Type': 'text/html'});
|
||||
|
||||
await agent.post('/receive/')
|
||||
.body({
|
||||
source: sourceUrl.href,
|
||||
target: targetUrl.href
|
||||
})
|
||||
.expectStatus(202);
|
||||
|
||||
await allSettled();
|
||||
|
||||
emailMockReceiver.sentEmailCount(0);
|
||||
});
|
||||
|
||||
it('can verify a webmention <a> link', async function () {
|
||||
const targetUrl = new URL(urlUtils.getSiteUrl());
|
||||
const sourceUrl = new URL('http://testpage.com/external-article-2/');
|
||||
|
|
|
@ -78,8 +78,8 @@ class StaffService {
|
|||
|
||||
/** @private */
|
||||
async handleEvent(type, event) {
|
||||
if (type === MentionCreatedEvent && event.data.mention && this.labs.isSet('webmentions')) {
|
||||
await this.emails.notifyMentionReceived(event.data);
|
||||
if (type === MentionCreatedEvent && event.data.mention && this.labs.isSet('webmentions') && this.labs.isSet('webmentionEmails')) {
|
||||
return await this.emails.notifyMentionReceived(event.data);
|
||||
}
|
||||
|
||||
if (type === MilestoneCreatedEvent && event.data.milestone && this.labs.isSet('milestoneEmails')) {
|
||||
|
|
|
@ -281,6 +281,9 @@ describe('StaffService', function () {
|
|||
if (flag === 'webmentions') {
|
||||
return true;
|
||||
}
|
||||
if (flag === 'webmentionEmails') {
|
||||
return true;
|
||||
}
|
||||
if (flag === 'milestoneEmails') {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue