mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Move content back up because it has side-effects with pubkeys
This commit is contained in:
parent
f72fdf79bb
commit
79e87008c1
1 changed files with 27 additions and 23 deletions
|
|
@ -149,6 +149,26 @@ const createStatusController: AppController = async (c) => {
|
||||||
|
|
||||||
const pubkeys = new Set<string>();
|
const pubkeys = new Set<string>();
|
||||||
|
|
||||||
|
let content = await asyncReplaceAll(
|
||||||
|
data.status ?? '',
|
||||||
|
/(?<![\w/])@([\w@+._]+)(?![\w/\.])/g,
|
||||||
|
async (match, username) => {
|
||||||
|
const pubkey = await lookupPubkey(username);
|
||||||
|
if (!pubkey) return match;
|
||||||
|
|
||||||
|
// Content addressing (default)
|
||||||
|
if (!data.to) {
|
||||||
|
pubkeys.add(pubkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return `nostr:${nip19.nprofileEncode({ pubkey, relays: [Conf.relay] })}`;
|
||||||
|
} catch {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Explicit addressing
|
// Explicit addressing
|
||||||
for (const to of data.to ?? []) {
|
for (const to of data.to ?? []) {
|
||||||
const pubkey = await lookupPubkey(to);
|
const pubkey = await lookupPubkey(to);
|
||||||
|
|
@ -207,33 +227,17 @@ const createStatusController: AppController = async (c) => {
|
||||||
.map(({ url }) => url)
|
.map(({ url }) => url)
|
||||||
.filter((url): url is string => Boolean(url));
|
.filter((url): url is string => Boolean(url));
|
||||||
|
|
||||||
let content = await asyncReplaceAll(
|
|
||||||
data.status ?? '',
|
|
||||||
/(?<![\w/])@([\w@+._]+)(?![\w/\.])/g,
|
|
||||||
async (match, username) => {
|
|
||||||
const pubkey = await lookupPubkey(username);
|
|
||||||
if (!pubkey) return match;
|
|
||||||
|
|
||||||
// Content addressing (default)
|
|
||||||
if (!data.to) {
|
|
||||||
pubkeys.add(pubkey);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return `nostr:${nip19.nprofileEncode({ pubkey, relays: [Conf.relay] })}`;
|
|
||||||
} catch {
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (quoted) {
|
if (quoted) {
|
||||||
if (content) {
|
if (content) {
|
||||||
content += '\n\n';
|
content += '\n\n';
|
||||||
}
|
}
|
||||||
content += `nostr:${
|
const nevent = nip19.neventEncode({
|
||||||
nip19.neventEncode({ id: quoted.id, kind: quoted.kind, author: quoted.pubkey, relays: [Conf.relay] })
|
id: quoted.id,
|
||||||
}`;
|
kind: quoted.kind,
|
||||||
|
author: quoted.pubkey,
|
||||||
|
relays: [Conf.relay],
|
||||||
|
});
|
||||||
|
content += `nostr:${nevent}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaUrls.length) {
|
if (mediaUrls.length) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue