forked from FoundKeyGang/FoundKey
activitypub: correctly handle new notes that were edited
This commit is contained in:
parent
cc776a6b9b
commit
9b4e976bda
3 changed files with 4 additions and 3 deletions
|
@ -20,8 +20,6 @@ export async function update(actor: IRemoteUser, note: IObject, resolver: Resolv
|
||||||
try {
|
try {
|
||||||
// if creating was successful...
|
// if creating was successful...
|
||||||
const existsNow = await Notes.findOneByOrFail({ uri });
|
const existsNow = await Notes.findOneByOrFail({ uri });
|
||||||
// set the updatedAt timestamp since the note was changed
|
|
||||||
await Notes.update(existsNow.id, { updatedAt: new Date() });
|
|
||||||
return 'ok: unknown note created and marked as updated';
|
return 'ok: unknown note created and marked as updated';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return `skip: updated note unknown and creating rejected: ${e.message}`;
|
return `skip: updated note unknown and creating rejected: ${e.message}`;
|
||||||
|
|
|
@ -278,6 +278,7 @@ export async function createNote(value: string | IObject, resolver: Resolver, si
|
||||||
return await post(actor, {
|
return await post(actor, {
|
||||||
...processedContent,
|
...processedContent,
|
||||||
createdAt: note.published ? new Date(note.published) : null,
|
createdAt: note.published ? new Date(note.published) : null,
|
||||||
|
updatedAt: note.updated,
|
||||||
reply,
|
reply,
|
||||||
renote: quote,
|
renote: quote,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
|
@ -354,7 +355,7 @@ export async function updateNote(value: IPost, actor: User, resolver: Resolver):
|
||||||
|
|
||||||
// update note content itself
|
// update note content itself
|
||||||
await Notes.update(exists.id, {
|
await Notes.update(exists.id, {
|
||||||
updatedAt: new Date(),
|
updatedAt: value.updated ?? new Date(),
|
||||||
|
|
||||||
cw: processedContent.cw,
|
cw: processedContent.cw,
|
||||||
fileIds: processedContent.files.map(file => file.id),
|
fileIds: processedContent.files.map(file => file.id),
|
||||||
|
|
|
@ -26,6 +26,7 @@ type MinimumUser = {
|
||||||
|
|
||||||
type Option = {
|
type Option = {
|
||||||
createdAt?: Date | null;
|
createdAt?: Date | null;
|
||||||
|
updatedAt?: Date | null;
|
||||||
name?: string | null;
|
name?: string | null;
|
||||||
text?: string | null;
|
text?: string | null;
|
||||||
reply?: Note | null;
|
reply?: Note | null;
|
||||||
|
@ -159,6 +160,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
|
||||||
const insert = new Note({
|
const insert = new Note({
|
||||||
id: genId(createdAt),
|
id: genId(createdAt),
|
||||||
createdAt,
|
createdAt,
|
||||||
|
updatedAt: data.updatedAt ?? null,
|
||||||
fileIds: data.files?.map(file => file.id) ?? [],
|
fileIds: data.files?.map(file => file.id) ?? [],
|
||||||
replyId: data.reply?.id ?? null,
|
replyId: data.reply?.id ?? null,
|
||||||
renoteId: data.renote?.id ?? null,
|
renoteId: data.renote?.id ?? null,
|
||||||
|
|
Loading…
Reference in a new issue