summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteEditService.ts
diff options
context:
space:
mode:
authorJulia <julia@insertdomain.name>2024-12-31 02:30:13 +0000
committerJulia <julia@insertdomain.name>2024-12-31 02:30:13 +0000
commit4c0bbddd0fba7e0d76fb484312e691ee29fe5858 (patch)
tree4bb1a3a2a79c679ac021a2199bd526be469524d4 /packages/backend/src/core/NoteEditService.ts
parentmerge: fixes for 2024.9.4 (if we want to) (!770) (diff)
parentBump version (diff)
downloadsharkey-4c0bbddd0fba7e0d76fb484312e691ee29fe5858.tar.gz
sharkey-4c0bbddd0fba7e0d76fb484312e691ee29fe5858.tar.bz2
sharkey-4c0bbddd0fba7e0d76fb484312e691ee29fe5858.zip
merge: Bump stable version (!842)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/842
Diffstat (limited to 'packages/backend/src/core/NoteEditService.ts')
-rw-r--r--packages/backend/src/core/NoteEditService.ts32
1 files changed, 19 insertions, 13 deletions
diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts
index d31958e5d4..f1c7bcbea5 100644
--- a/packages/backend/src/core/NoteEditService.ts
+++ b/packages/backend/src/core/NoteEditService.ts
@@ -220,7 +220,7 @@ export class NoteEditService implements OnApplicationShutdown {
private latestNoteService: LatestNoteService,
private noteCreateService: NoteCreateService,
) {
- this.updateNotesCountQueue = new CollapsedQueue(60 * 1000 * 5, this.collapseNotesCount, this.performUpdateNotesCount);
+ this.updateNotesCountQueue = new CollapsedQueue(process.env.NODE_ENV !== 'test' ? 60 * 1000 * 5 : 0, this.collapseNotesCount, this.performUpdateNotesCount);
}
@bindThis
@@ -441,8 +441,8 @@ export class NoteEditService implements OnApplicationShutdown {
}
if (user.host && !data.cw) {
- await this.federatedInstanceService.fetch(user.host).then(async i => {
- if (i.isNSFW) {
+ await this.federatedInstanceService.fetchOrRegister(user.host).then(async i => {
+ if (i.isNSFW && !this.noteCreateService.isPureRenote(data)) {
data.cw = 'Instance is marked as NSFW';
}
});
@@ -471,8 +471,9 @@ export class NoteEditService implements OnApplicationShutdown {
const poll = await this.pollsRepository.findOneBy({ noteId: oldnote.id });
const oldPoll = poll ? { choices: poll.choices, multiple: poll.multiple, expiresAt: poll.expiresAt } : null;
+ const pollChanged = data.poll != null && JSON.stringify(data.poll) !== JSON.stringify(oldPoll);
- if (Object.keys(update).length > 0 || filesChanged) {
+ if (Object.keys(update).length > 0 || filesChanged || pollChanged) {
const exists = await this.noteEditRepository.findOneBy({ noteId: oldnote.id });
await this.noteEditRepository.insert({
@@ -544,7 +545,7 @@ export class NoteEditService implements OnApplicationShutdown {
}));
}
- if (data.poll != null && JSON.stringify(data.poll) !== JSON.stringify(oldPoll)) {
+ if (pollChanged) {
// Start transaction
await this.db.transaction(async transactionalEntityManager => {
await transactionalEntityManager.update(MiNote, oldnote.id, note);
@@ -591,13 +592,17 @@ export class NoteEditService implements OnApplicationShutdown {
noindex: MiUser['noindex'];
}, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) {
// Register host
- if (this.userEntityService.isRemoteUser(user)) {
- this.federatedInstanceService.fetch(user.host).then(async i => {
- this.updateNotesCountQueue.enqueue(i.id, 1);
- if (this.meta.enableChartsForFederatedInstances) {
- this.instanceChart.updateNote(i.host, note, true);
- }
- });
+ if (this.meta.enableStatsForFederatedInstances) {
+ if (this.userEntityService.isRemoteUser(user)) {
+ this.federatedInstanceService.fetchOrRegister(user.host).then(async i => {
+ if (note.renote && note.text || !note.renote) {
+ this.updateNotesCountQueue.enqueue(i.id, 1);
+ }
+ if (this.meta.enableChartsForFederatedInstances) {
+ this.instanceChart.updateNote(i.host, note, true);
+ }
+ });
+ }
}
// ハッシュタグ更新
@@ -605,10 +610,11 @@ export class NoteEditService implements OnApplicationShutdown {
if (data.poll && data.poll.expiresAt) {
const delay = data.poll.expiresAt.getTime() - Date.now();
- this.queueService.endedPollNotificationQueue.remove(note.id);
+ this.queueService.endedPollNotificationQueue.remove(`pollEnd:${note.id}`);
this.queueService.endedPollNotificationQueue.add(note.id, {
noteId: note.id,
}, {
+ jobId: `pollEnd:${note.id}`,
delay,
removeOnComplete: true,
});