Skip to content
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

Added @tryghost/metrics-server as a dependency #21329

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ jobs:
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }}

- name: Set timezone (non-UTC)
uses: szenius/[email protected]
with:
timezoneLinux: "America/New_York"

- run: yarn nx affected -t test:unit --base=${{ needs.job_setup.outputs.BASE_COMMIT }}

- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -504,6 +509,11 @@ jobs:
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }}

- name: Set timezone (non-UTC)
uses: szenius/[email protected]
with:
timezoneLinux: "America/New_York"

- name: Record start time
run: date +%s > ${{ runner.temp }}/startTime # Get start time for test suite

Expand Down
2 changes: 1 addition & 1 deletion ghost/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghost-admin",
"version": "5.96.1",
"version": "5.96.2",
"description": "Ember.js admin client for Ghost",
"author": "Ghost Foundation",
"homepage": "http://ghost.org",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const _ = require('lodash');
const xml = require('xml');
const moment = require('moment');
const path = require('path');
const urlUtils = require('../../../shared/url-utils');
const localUtils = require('./utils');
Expand Down Expand Up @@ -95,24 +96,23 @@ class BaseSiteMapGenerator {
}

/**
* @returns {Date}
* @returns {moment.Moment}
*/
getLastModifiedForDatum(datum) {
if (datum.updated_at || datum.published_at || datum.created_at) {
const modifiedDate = datum.updated_at || datum.published_at || datum.created_at;

return new Date(modifiedDate);
return moment(modifiedDate);
} else {
return new Date();
return moment();
}
}

updateLastModified(datum) {
const lastModified = this.getLastModifiedForDatum(datum);
const lastModifiedTime = lastModified.getTime();

if (lastModifiedTime > this.lastModified) {
this.lastModified = lastModifiedTime;
if (lastModified > this.lastModified) {
this.lastModified = lastModified;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ function serializeMember(member, options) {
email_recipients: json.email_recipients,
status: json.status,
last_seen_at: json.last_seen_at,
attribution: serializeAttribution(json.attribution)
attribution: serializeAttribution(json.attribution),
unsubscribe_url: json.unsubscribe_url
};

if (json.products) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const {addPermissionToRole} = require('../../utils');

module.exports = addPermissionToRole({
permission: 'Read member signin urls',
role: 'Admin Integration'
});
3 changes: 2 additions & 1 deletion ghost/core/core/server/data/schema/fixtures/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@
"link": "all",
"mention": "browse",
"collection": "all",
"recommendation": "all"
"recommendation": "all",
"member_signin_url": "read"
},
"Editor": {
"notification": "all",
Expand Down
13 changes: 4 additions & 9 deletions ghost/core/core/server/models/base/plugins/data-manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,14 @@ module.exports = function (Bookshelf) {

Object.keys(attrs).forEach((key) => {
if (attrs[key] && tableDef?.[key]?.type === 'dateTime') {
const dateValue = new Date(attrs[key]);
const dateMoment = moment(attrs[key]);

// CASE: You are somehow able to store e.g. 0000-00-00 00:00:00
// Protect the code base and return the current date time.
if (!isNaN(dateValue.getTime())) {
// Valid date: set to the start of the second
dateValue.setMilliseconds(0);
attrs[key] = dateValue;
if (dateMoment.isValid()) {
attrs[key] = dateMoment.startOf('seconds').toDate();
} else {
// Invalid date: use current date-time
const currentDate = new Date();
currentDate.setMilliseconds(0);
attrs[key] = currentDate;
attrs[key] = moment().startOf('seconds').toDate();
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion ghost/core/core/server/services/members/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const stripeService = require('../stripe');
const settingsCache = require('../../../shared/settings-cache');
const settingsHelpers = require('../../services/settings-helpers');
const MembersApi = require('@tryghost/members-api');
const logging = require('@tryghost/logging');
const mail = require('../mail');
Expand Down Expand Up @@ -236,7 +237,8 @@ function createApiInstance(config) {
memberAttributionService: memberAttributionService.service,
emailSuppressionList,
settingsCache,
sentry
sentry,
settingsHelpers
});

return membersApiInstance;
Expand Down
1 change: 1 addition & 0 deletions ghost/core/core/server/services/members/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports.formattedMemberResponse = function formattedMemberResponse(member
firstname: member.name && member.name.split(' ')[0],
expertise: member.expertise,
avatar_image: member.avatar_image,
unsubscribe_url: member.unsubscribe_url,
subscribed: !!member.subscribed,
subscriptions: member.subscriptions || [],
paid: member.status !== 'free',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const {EmailAddressParser} = require('@tryghost/email-addresses');
const logging = require('@tryghost/logging');
const crypto = require('crypto');

const messages = {
incorrectKeyType: 'type must be one of "direct" or "connect".'
Expand Down Expand Up @@ -179,6 +180,30 @@ class SettingsHelpers {
return this.#managedEmailEnabled() || this.labs.isSet('newEmailAddresses');
}

createUnsubscribeUrl(uuid, options = {}) {
const siteUrl = this.urlUtils.urlFor('home', true);
const unsubscribeUrl = new URL(siteUrl);
const key = this.getMembersValidationKey();
unsubscribeUrl.pathname = `${unsubscribeUrl.pathname}/unsubscribe/`.replace('//', '/');
if (uuid) {
// hash key with member uuid for verification (and to not leak uuid) - it's possible to update member email prefs without logging in
// @ts-ignore
const hmac = crypto.createHmac('sha256', key).update(`${uuid}`).digest('hex');
unsubscribeUrl.searchParams.set('uuid', uuid);
unsubscribeUrl.searchParams.set('key', hmac);
} else {
unsubscribeUrl.searchParams.set('preview', '1');
}
if (options.newsletterUuid) {
unsubscribeUrl.searchParams.set('newsletter', options.newsletterUuid);
}
if (options.comments) {
unsubscribeUrl.searchParams.set('comments', '1');
}

return unsubscribeUrl.href;
}

// PRIVATE

#managedEmailEnabled() {
Expand Down
3 changes: 2 additions & 1 deletion ghost/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "5.96.1",
"version": "5.96.2",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",
Expand Down Expand Up @@ -126,6 +126,7 @@
"@tryghost/members-stripe-service": "0.0.0",
"@tryghost/mentions-email-report": "0.0.0",
"@tryghost/metrics": "1.0.34",
"@tryghost/metrics-server": "0.0.0",
"@tryghost/milestones": "0.0.0",
"@tryghost/minifier": "0.0.0",
"@tryghost/model-to-domain-event-interceptor": "0.0.0",
Expand Down
Loading
Loading