mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-19 23:10:21 +01:00
fix: regression caused by d3b3720915
This commit is contained in:
@@ -18,6 +18,7 @@ module.exports = function (Posts) {
|
|||||||
const content = data.content.toString();
|
const content = data.content.toString();
|
||||||
const timestamp = data.timestamp || Date.now();
|
const timestamp = data.timestamp || Date.now();
|
||||||
const isMain = data.isMain || false;
|
const isMain = data.isMain || false;
|
||||||
|
let hasAttachment = false;
|
||||||
|
|
||||||
if (!uid && parseInt(uid, 10) !== 0) {
|
if (!uid && parseInt(uid, 10) !== 0) {
|
||||||
throw new Error('[[error:invalid-uid]]');
|
throw new Error('[[error:invalid-uid]]');
|
||||||
@@ -46,23 +47,25 @@ module.exports = function (Posts) {
|
|||||||
if (_activitypub.audience) {
|
if (_activitypub.audience) {
|
||||||
postData.audience = _activitypub.audience;
|
postData.audience = _activitypub.audience;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Rewrite emoji references to inline image assets
|
// Rewrite emoji references to inline image assets
|
||||||
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
||||||
_activitypub.tag
|
_activitypub.tag
|
||||||
.filter(tag => tag.type === 'Emoji' &&
|
.filter(tag => tag.type === 'Emoji' &&
|
||||||
tag.icon && tag.icon.type === 'Image')
|
tag.icon && tag.icon.type === 'Image')
|
||||||
.forEach((tag) => {
|
.forEach((tag) => {
|
||||||
if (!tag.name.startsWith(':')) {
|
if (!tag.name.startsWith(':')) {
|
||||||
tag.name = `:${tag.name}`;
|
tag.name = `:${tag.name}`;
|
||||||
}
|
}
|
||||||
if (!tag.name.endsWith(':')) {
|
if (!tag.name.endsWith(':')) {
|
||||||
tag.name = `${tag.name}:`;
|
tag.name = `${tag.name}:`;
|
||||||
}
|
}
|
||||||
|
|
||||||
postData.content = postData.content.replace(new RegExp(tag.name, 'g'), `<img class="not-responsive emoji" src="${tag.icon.url}" title="${tag.name}" />`);
|
postData.content = postData.content.replace(new RegExp(tag.name, 'g'), `<img class="not-responsive emoji" src="${tag.icon.url}" title="${tag.name}" />`);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hasAttachment = _activitypub && _activitypub.attachment && _activitypub.attachment.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }));
|
({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }));
|
||||||
@@ -71,8 +74,6 @@ module.exports = function (Posts) {
|
|||||||
const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']);
|
const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']);
|
||||||
postData.cid = topicData.cid;
|
postData.cid = topicData.cid;
|
||||||
|
|
||||||
const hasAttachment = _activitypub && _activitypub.attachment && _activitypub.attachment.length;
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.sortedSetAdd('posts:pid', timestamp, postData.pid),
|
db.sortedSetAdd('posts:pid', timestamp, postData.pid),
|
||||||
utils.isNumber(pid) ? db.incrObjectField('global', 'postCount') : null,
|
utils.isNumber(pid) ? db.incrObjectField('global', 'postCount') : null,
|
||||||
|
|||||||
Reference in New Issue
Block a user