mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
c7ef22d4df
fixes https://github.com/TryGhost/Team/issues/2174 The feedback links now use a hash instead of a querystring, so it won't pass by the server. New format: https://site.ghost/post-slug/#/feedback/6359174f2eb251019d14d6fb/0?uuid=13924399-c3ae-413b-a045-0b8294d71f64
34 lines
894 B
JavaScript
34 lines
894 B
JavaScript
class AudienceFeedbackService {
|
|
/** @type URL */
|
|
#baseURL;
|
|
/** @type {Object} */
|
|
#urlService;
|
|
/**
|
|
* @param {object} deps
|
|
* @param {object} deps.config
|
|
* @param {URL} deps.config.baseURL
|
|
* @param {object} deps.urlService
|
|
*/
|
|
constructor(deps) {
|
|
this.#baseURL = deps.config.baseURL;
|
|
this.#urlService = deps.urlService;
|
|
}
|
|
/**
|
|
* @param {string} uuid
|
|
* @param {string} postId
|
|
* @param {0 | 1} score
|
|
*/
|
|
buildLink(uuid, postId, score) {
|
|
let postUrl = this.#urlService.getUrlByResourceId(postId, {absolute: true});
|
|
|
|
if (postUrl.match(/\/404\//)) {
|
|
postUrl = this.#baseURL;
|
|
}
|
|
const url = new URL(postUrl);
|
|
url.hash = `#/feedback/${postId}/${score}/?uuid=${encodeURIComponent(uuid)}`;
|
|
return url;
|
|
}
|
|
}
|
|
|
|
module.exports = AudienceFeedbackService;
|