mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-30 23:26:44 -06:00
fix(edit): add missing updated
field
This commit is contained in:
parent
70a1c308f0
commit
678aa493de
5 changed files with 11 additions and 8 deletions
|
@ -3,11 +3,10 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Brackets, In } from 'typeorm';
|
|
||||||
import { Injectable, Inject } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
import * as mfm from 'mfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||||
import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js';
|
import type { MiNote } from '@/models/Note.js';
|
||||||
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
||||||
import { RelayService } from '@/core/RelayService.js';
|
import { RelayService } from '@/core/RelayService.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
|
@ -68,7 +67,7 @@ export class NoteUpdateService {
|
||||||
* @param note Note to update
|
* @param note Note to update
|
||||||
* @param ps New note info
|
* @param ps New note info
|
||||||
*/
|
*/
|
||||||
async update(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, ps: Pick<MiNote, 'text' | 'cw'>, quiet = false, updater?: MiUser) {
|
async update(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, ps: Pick<MiNote, 'text' | 'cw' | 'updatedAt'>, quiet = false, updater?: MiUser) {
|
||||||
const newNote = {
|
const newNote = {
|
||||||
...note,
|
...note,
|
||||||
...ps, // Overwrite updated fields
|
...ps, // Overwrite updated fields
|
||||||
|
@ -94,7 +93,7 @@ export class NoteUpdateService {
|
||||||
this.searchService.indexNote(newNote);
|
this.searchService.indexNote(newNote);
|
||||||
|
|
||||||
await this.notesRepository.update({ id: note.id }, {
|
await this.notesRepository.update({ id: note.id }, {
|
||||||
updatedAt: new Date(),
|
updatedAt: ps.updatedAt,
|
||||||
history: [...(note.history || []), {
|
history: [...(note.history || []), {
|
||||||
createdAt: (note.updatedAt || this.idService.parse(note.id).date).toISOString(),
|
createdAt: (note.updatedAt || this.idService.parse(note.id).date).toISOString(),
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
|
|
|
@ -425,6 +425,7 @@ export class ApRendererService {
|
||||||
return {
|
return {
|
||||||
id: `${this.config.url}/notes/${note.id}`,
|
id: `${this.config.url}/notes/${note.id}`,
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
|
updated: note.updatedAt ?? undefined,
|
||||||
attributedTo,
|
attributedTo,
|
||||||
summary: summary ?? undefined,
|
summary: summary ?? undefined,
|
||||||
content: content ?? undefined,
|
content: content ?? undefined,
|
||||||
|
|
|
@ -363,9 +363,12 @@ export class ApNoteService {
|
||||||
text = this.apMfmService.htmlToMfm(note.content, note.tag);
|
text = this.apMfmService.htmlToMfm(note.content, note.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updatedAt = note.updated || new Date();
|
||||||
|
|
||||||
await this.noteUpdateService.update(actor, originNote, {
|
await this.noteUpdateService.update(actor, originNote, {
|
||||||
cw,
|
cw,
|
||||||
text,
|
text,
|
||||||
|
updatedAt,
|
||||||
}, silent);
|
}, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ export interface IPost extends IObject {
|
||||||
_misskey_quote?: string;
|
_misskey_quote?: string;
|
||||||
_misskey_content?: string;
|
_misskey_content?: string;
|
||||||
quoteUrl?: string;
|
quoteUrl?: string;
|
||||||
|
updated?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IQuestion extends IObject {
|
export interface IQuestion extends IObject {
|
||||||
|
|
|
@ -5,14 +5,12 @@
|
||||||
|
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { UsersRepository, NotesRepository } from '@/models/_.js';
|
import type { UsersRepository } from '@/models/_.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '@/server/api/error.js';
|
||||||
import { IdService } from "@/core/IdService.js";
|
|
||||||
import { NoteUpdateService } from '@/core/NoteUpdateService.js';
|
import { NoteUpdateService } from '@/core/NoteUpdateService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -75,6 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
await this.noteUpdateService.update(await this.usersRepository.findOneByOrFail({ id: note.userId }), note, {
|
await this.noteUpdateService.update(await this.usersRepository.findOneByOrFail({ id: note.userId }), note, {
|
||||||
text: ps.text,
|
text: ps.text,
|
||||||
cw: ps.cw,
|
cw: ps.cw,
|
||||||
|
updatedAt: new Date(),
|
||||||
}, false, me);
|
}, false, me);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue