forked from FoundKeyGang/FoundKey
activitypub: remove akkoma quote URLs
Changelog: Fixed
This commit is contained in:
parent
512351746f
commit
66a7c62342
3 changed files with 15 additions and 5 deletions
|
@ -7,7 +7,7 @@ const treeAdapter = parse5.defaultTreeAdapter;
|
||||||
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
||||||
const urlRegexFull = /^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(
|
const dom = parse5.parseFragment(
|
||||||
// some AP servers like Pixelfed use br tags as well as newlines
|
// some AP servers like Pixelfed use br tags as well as newlines
|
||||||
html.replace(/<br\s?\/?>\r?\n/gi, '\n'),
|
html.replace(/<br\s?\/?>\r?\n/gi, '\n'),
|
||||||
|
@ -202,6 +202,16 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
break;
|
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
|
default: // includes inline elements
|
||||||
{
|
{
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { IObject } from '../type.js';
|
||||||
import { extractApHashtagObjects } from '../models/tag.js';
|
import { extractApHashtagObjects } from '../models/tag.js';
|
||||||
import { fromHtml } from '@/mfm/from-html.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);
|
const hashtagNames = extractApHashtagObjects(tag).map(x => x.name).filter((x): x is string => x != null);
|
||||||
|
|
||||||
return fromHtml(html, hashtagNames);
|
return fromHtml(html, hashtagNames, quoteUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,14 +194,14 @@ export async function createNote(value: string | IObject, resolver?: Resolver =
|
||||||
|
|
||||||
const cw = note.summary === '' ? null : note.summary;
|
const cw = note.summary === '' ? null : note.summary;
|
||||||
|
|
||||||
// テキストのパース
|
// text parsing
|
||||||
let text: string | null = null;
|
let text: string | null = null;
|
||||||
if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source.content === 'string') {
|
if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source.content === 'string') {
|
||||||
text = note.source.content;
|
text = note.source.content;
|
||||||
} else if (typeof note._misskey_content !== 'undefined') {
|
} else if (typeof note._misskey_content !== 'undefined') {
|
||||||
text = note._misskey_content;
|
text = note._misskey_content;
|
||||||
} else if (typeof note.content === 'string') {
|
} else if (typeof note.content === 'string') {
|
||||||
text = htmlToMfm(note.content, note.tag);
|
text = htmlToMfm(note.content, note.tag, quote.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vote
|
// vote
|
||||||
|
|
Loading…
Reference in a new issue