mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +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 timestamp = data.timestamp || Date.now();
|
||||
const isMain = data.isMain || false;
|
||||
let hasAttachment = false;
|
||||
|
||||
if (!uid && parseInt(uid, 10) !== 0) {
|
||||
throw new Error('[[error:invalid-uid]]');
|
||||
@@ -46,23 +47,25 @@ module.exports = function (Posts) {
|
||||
if (_activitypub.audience) {
|
||||
postData.audience = _activitypub.audience;
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite emoji references to inline image assets
|
||||
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
||||
_activitypub.tag
|
||||
.filter(tag => tag.type === 'Emoji' &&
|
||||
tag.icon && tag.icon.type === 'Image')
|
||||
.forEach((tag) => {
|
||||
if (!tag.name.startsWith(':')) {
|
||||
tag.name = `:${tag.name}`;
|
||||
}
|
||||
if (!tag.name.endsWith(':')) {
|
||||
tag.name = `${tag.name}:`;
|
||||
}
|
||||
// Rewrite emoji references to inline image assets
|
||||
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
||||
_activitypub.tag
|
||||
.filter(tag => tag.type === 'Emoji' &&
|
||||
tag.icon && tag.icon.type === 'Image')
|
||||
.forEach((tag) => {
|
||||
if (!tag.name.startsWith(':')) {
|
||||
tag.name = `:${tag.name}`;
|
||||
}
|
||||
if (!tag.name.endsWith(':')) {
|
||||
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 }));
|
||||
@@ -71,8 +74,6 @@ module.exports = function (Posts) {
|
||||
const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']);
|
||||
postData.cid = topicData.cid;
|
||||
|
||||
const hasAttachment = _activitypub && _activitypub.attachment && _activitypub.attachment.length;
|
||||
|
||||
await Promise.all([
|
||||
db.sortedSetAdd('posts:pid', timestamp, postData.pid),
|
||||
utils.isNumber(pid) ? db.incrObjectField('global', 'postCount') : null,
|
||||
|
||||
Reference in New Issue
Block a user