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 {
|
||||
// if creating was successful...
|
||||
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';
|
||||
} catch (e) {
|
||||
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, {
|
||||
...processedContent,
|
||||
createdAt: note.published ? new Date(note.published) : null,
|
||||
updatedAt: note.updated,
|
||||
reply,
|
||||
renote: quote,
|
||||
localOnly: false,
|
||||
|
@ -354,7 +355,7 @@ export async function updateNote(value: IPost, actor: User, resolver: Resolver):
|
|||
|
||||
// update note content itself
|
||||
await Notes.update(exists.id, {
|
||||
updatedAt: new Date(),
|
||||
updatedAt: value.updated ?? new Date(),
|
||||
|
||||
cw: processedContent.cw,
|
||||
fileIds: processedContent.files.map(file => file.id),
|
||||
|
|
|
@ -26,6 +26,7 @@ type MinimumUser = {
|
|||
|
||||
type Option = {
|
||||
createdAt?: Date | null;
|
||||
updatedAt?: Date | null;
|
||||
name?: string | null;
|
||||
text?: string | null;
|
||||
reply?: Note | null;
|
||||
|
@ -159,6 +160,7 @@ async function insertNote(user: { id: User['id']; host: User['host']; }, data: O
|
|||
const insert = new Note({
|
||||
id: genId(createdAt),
|
||||
createdAt,
|
||||
updatedAt: data.updatedAt ?? null,
|
||||
fileIds: data.files?.map(file => file.id) ?? [],
|
||||
replyId: data.reply?.id ?? null,
|
||||
renoteId: data.renote?.id ?? null,
|
||||
|
|
Loading…
Reference in a new issue