mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
feat: native parsing of title for topics
This commit is contained in:
@@ -74,7 +74,8 @@ Mocks.post = async (objects) => {
|
||||
}
|
||||
|
||||
const posts = await Promise.all(objects.map(async (object) => {
|
||||
if (object.type !== 'Note') {
|
||||
const acceptedTypes = ['Note', 'Page', 'Article'];
|
||||
if (!acceptedTypes.includes(object.type)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -84,6 +85,7 @@ Mocks.post = async (objects) => {
|
||||
updated,
|
||||
attributedTo: uid,
|
||||
// conversation,
|
||||
name,
|
||||
content,
|
||||
sourceContent,
|
||||
inReplyTo: toPid,
|
||||
@@ -96,7 +98,8 @@ Mocks.post = async (objects) => {
|
||||
const payload = {
|
||||
uid,
|
||||
pid,
|
||||
// tid,
|
||||
// tid, --> purposely omitted
|
||||
name,
|
||||
content,
|
||||
sourceContent,
|
||||
timestamp,
|
||||
|
||||
@@ -5,6 +5,7 @@ const winston = require('winston');
|
||||
const db = require('../database');
|
||||
const topics = require('../topics');
|
||||
const posts = require('../posts');
|
||||
const utils = require('../utils');
|
||||
|
||||
const activitypub = module.parent.exports;
|
||||
const Notes = module.exports;
|
||||
@@ -91,7 +92,7 @@ Notes.assertTopic = async (uid, id) => {
|
||||
*/
|
||||
|
||||
const chain = Array.from(await Notes.getParentChain(uid, id));
|
||||
const { pid: tid, uid: authorId, timestamp } = chain[chain.length - 1];
|
||||
const { pid: tid, uid: authorId, timestamp, name, content } = chain[chain.length - 1];
|
||||
|
||||
const members = await db.isSortedSetMembers(`tidRemote:${tid}:posts`, chain.map(p => p.pid));
|
||||
if (members.every(Boolean)) {
|
||||
@@ -100,6 +101,11 @@ Notes.assertTopic = async (uid, id) => {
|
||||
return tid;
|
||||
}
|
||||
|
||||
let title = name || utils.stripHTMLTags(content);
|
||||
if (title.length > 256) {
|
||||
title = `${title.slice(0, 256)}...`;
|
||||
}
|
||||
|
||||
const cid = await topics.getTopicField(tid, 'cid');
|
||||
|
||||
const unprocessed = chain.filter((p, idx) => !members[idx]);
|
||||
@@ -116,7 +122,7 @@ Notes.assertTopic = async (uid, id) => {
|
||||
uid: authorId,
|
||||
cid: cid || -1,
|
||||
mainPid: tid,
|
||||
title: 'TBD',
|
||||
title,
|
||||
slug: `remote?resource=${encodeURIComponent(tid)}`,
|
||||
timestamp,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user