Revert "fix: urls in posts and announces"

This reverts commit 4fb6574cf7.
This commit is contained in:
Julian Lam
2024-03-20 23:18:12 -04:00
parent c9985c5cd6
commit 6fa43b9ef0
2 changed files with 3 additions and 11 deletions

View File

@@ -25,7 +25,6 @@ module.exports = function (utils, Benchpress, relative_path) {
userAgentIcons, userAgentIcons,
buildAvatar, buildAvatar,
increment, increment,
generatePostUrl,
generateRepliedTo, generateRepliedTo,
generateWrote, generateWrote,
isoTimeToLocaleString, isoTimeToLocaleString,
@@ -336,24 +335,18 @@ module.exports = function (utils, Benchpress, relative_path) {
return String(value + parseInt(inc, 10)); return String(value + parseInt(inc, 10));
} }
function generatePostUrl(post, property = 'pid') {
return utils.isNumber(post[property]) ? `${relative_path}/post/${post[property]}` : post[property];
}
function generateRepliedTo(post, timeagoCutoff) { function generateRepliedTo(post, timeagoCutoff) {
const displayname = post.parent && post.parent.displayname ? const displayname = post.parent && post.parent.displayname ?
post.parent.displayname : '[[global:guest]]'; post.parent.displayname : '[[global:guest]]';
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs)); const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
const langSuffix = isBeforeCutoff ? 'on' : 'ago'; const langSuffix = isBeforeCutoff ? 'on' : 'ago';
const url = generatePostUrl(post, 'toPid'); return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${post.toPid}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${url}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
} }
function generateWrote(post, timeagoCutoff) { function generateWrote(post, timeagoCutoff) {
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs)); const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
const langSuffix = isBeforeCutoff ? 'on' : 'ago'; const langSuffix = isBeforeCutoff ? 'on' : 'ago';
const url = generatePostUrl(post); return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
return `[[topic:wrote-${langSuffix}, ${url}, ${post.timestampISO}]]`;
} }
function isoTimeToLocaleString(isoTime, locale = 'en-GB') { function isoTimeToLocaleString(isoTime, locale = 'en-GB') {

View File

@@ -10,7 +10,6 @@ const posts = require('../posts');
const topics = require('../topics'); const topics = require('../topics');
const categories = require('../categories'); const categories = require('../categories');
const notifications = require('../notifications'); const notifications = require('../notifications');
const utils = require('../utils');
const activitypub = require('.'); const activitypub = require('.');
const socketHelpers = require('../socket.io/helpers'); const socketHelpers = require('../socket.io/helpers');
@@ -155,7 +154,7 @@ inbox.announce = async (req) => {
await topics.events.log(tid, { await topics.events.log(tid, {
type: 'announce', type: 'announce',
uid: actor, uid: actor,
href: utils.isNumber(pid) ? `/post/${pid}` : pid, href: `/post/${pid}`,
pid, pid,
timestamp, timestamp,
}); });