Merge branch 'develop' into feature/2024.10
This commit is contained in:
commit
eb25238a8e
257 changed files with 3053 additions and 68 deletions
|
|
@ -637,6 +637,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
this.queueService.endedPollNotificationQueue.add(note.id, {
|
||||
noteId: note.id,
|
||||
}, {
|
||||
jobId: `pollEnd:${note.id}`,
|
||||
delay,
|
||||
removeOnComplete: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -609,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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -469,6 +469,7 @@ export class ApRendererService {
|
|||
};
|
||||
}
|
||||
|
||||
// if you change this, also change `server/api/endpoints/i/update.ts`
|
||||
@bindThis
|
||||
public async renderPerson(user: MiLocalUser) {
|
||||
const id = this.userEntityService.genLocalUserUri(user.id);
|
||||
|
|
|
|||
|
|
@ -2,26 +2,29 @@
|
|||
* SPDX-FileCopyrightText: dakkar and sharkey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { IObject } from '../type.js';
|
||||
|
||||
function getHrefFrom(one: IObject|string): string | undefined {
|
||||
if (typeof(one) === 'string') return one;
|
||||
return one.href;
|
||||
function getHrefsFrom(one: IObject | string | undefined | (IObject | string | undefined)[]): (string | undefined)[] {
|
||||
if (Array.isArray(one)) {
|
||||
return one.flatMap(h => getHrefsFrom(h));
|
||||
}
|
||||
return [
|
||||
typeof(one) === 'object' ? one.href : one,
|
||||
];
|
||||
}
|
||||
|
||||
export function assertActivityMatchesUrls(activity: IObject, urls: string[]) {
|
||||
const idOk = activity.id !== undefined && urls.includes(activity.id);
|
||||
if (idOk) return;
|
||||
const expectedUrls = new Set(urls
|
||||
.filter(u => URL.canParse(u))
|
||||
.map(u => new URL(u).href),
|
||||
);
|
||||
|
||||
const url = activity.url;
|
||||
if (url) {
|
||||
// `activity.url` can be an `ApObject = IObject | string | (IObject
|
||||
// | string)[]`, we have to look inside it
|
||||
const activityUrls = Array.isArray(url) ? url.map(getHrefFrom) : [getHrefFrom(url)];
|
||||
const goodUrl = activityUrls.find(u => u && urls.includes(u));
|
||||
const actualUrls = [activity.id, ...getHrefsFrom(activity.url)]
|
||||
.filter(u => u && URL.canParse(u))
|
||||
.map(u => new URL(u as string).href);
|
||||
|
||||
if (goodUrl) return;
|
||||
if (!actualUrls.some(u => expectedUrls.has(u))) {
|
||||
throw new Error(`bad Activity: neither id(${activity.id}) nor url(${JSON.stringify(activity.url)}) match location(${urls})`);
|
||||
}
|
||||
|
||||
throw new Error(`bad Activity: neither id(${activity?.id}) nor url(${JSON.stringify(activity?.url)}) match location(${urls})`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,8 +218,8 @@ export class NoteEntityService implements OnModuleInit {
|
|||
packedNote.reactionAcceptance = null;
|
||||
packedNote.reactionAndUserPairCache = undefined;
|
||||
packedNote.reactionCount = 0;
|
||||
packedNote.reactionEmojis = undefined;
|
||||
packedNote.reactions = undefined;
|
||||
packedNote.reactionEmojis = {};
|
||||
packedNote.reactions = {};
|
||||
packedNote.isHidden = true;
|
||||
// TODO: hiddenReason みたいなのを提供しても良さそう
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue