activitypub: remove akkoma quote URLs

Changelog: Fixed
This commit is contained in:
Johann150 2022-11-19 22:48:04 +01:00 committed by Gitea
parent 512351746f
commit 66a7c62342
3 changed files with 15 additions and 5 deletions

View file

@ -7,7 +7,7 @@ const treeAdapter = parse5.defaultTreeAdapter;
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
export function fromHtml(html: string, hashtagNames?: string[]): string {
export function fromHtml(html: string, hashtagNames?: string[], quoteUri?: string | null): string {
const dom = parse5.parseFragment(
// some AP servers like Pixelfed use br tags as well as newlines
html.replace(/<br\s?\/?>\r?\n/gi, '\n'),
@ -202,6 +202,16 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
break;
}
case 'span':
{
if (node.classList.contains('quote-inline') && quoteUri && getText(node).trim() === `RE: ${quoteUri}`) {
// embedded quote thingy for backwards compatibility, don't show it
} else {
appendChildren(node.childNodes);
}
break;
}
default: // includes inline elements
{
appendChildren(node.childNodes);

View file

@ -2,8 +2,8 @@ import { IObject } from '../type.js';
import { extractApHashtagObjects } from '../models/tag.js';
import { fromHtml } from '@/mfm/from-html.js';
export function htmlToMfm(html: string, tag?: IObject | IObject[]) {
export function htmlToMfm(html: string, tag?: IObject | IObject[], quoteUri?: string | null) {
const hashtagNames = extractApHashtagObjects(tag).map(x => x.name).filter((x): x is string => x != null);
return fromHtml(html, hashtagNames);
return fromHtml(html, hashtagNames, quoteUri);
}

View file

@ -194,14 +194,14 @@ export async function createNote(value: string | IObject, resolver?: Resolver =
const cw = note.summary === '' ? null : note.summary;
// テキストのパース
// text parsing
let text: string | null = null;
if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source.content === 'string') {
text = note.source.content;
} else if (typeof note._misskey_content !== 'undefined') {
text = note._misskey_content;
} else if (typeof note.content === 'string') {
text = htmlToMfm(note.content, note.tag);
text = htmlToMfm(note.content, note.tag, quote.uri);
}
// vote