summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NotePiningService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core/NotePiningService.ts')
-rw-r--r--packages/backend/src/core/NotePiningService.ts17
1 files changed, 7 insertions, 10 deletions
diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts
index d38b48b65d..6ab7268254 100644
--- a/packages/backend/src/core/NotePiningService.ts
+++ b/packages/backend/src/core/NotePiningService.ts
@@ -49,7 +49,7 @@ export class NotePiningService {
* @param noteId
*/
@bindThis
- public async addPinned(user: { id: MiUser['id']; host: MiUser['host']; }, noteId: MiNote['id']) {
+ public async addPinned(user: MiUser, noteId: MiNote['id']) {
// Fetch pinee
const note = await this.notesRepository.findOneBy({
id: noteId,
@@ -78,7 +78,7 @@ export class NotePiningService {
// Deliver to remote followers
if (this.userEntityService.isLocalUser(user) && !note.localOnly && ['public', 'home'].includes(note.visibility)) {
- this.deliverPinnedChange(user.id, note.id, true);
+ this.deliverPinnedChange(user, note.id, true);
}
}
@@ -88,7 +88,7 @@ export class NotePiningService {
* @param noteId
*/
@bindThis
- public async removePinned(user: { id: MiUser['id']; host: MiUser['host']; }, noteId: MiNote['id']) {
+ public async removePinned(user: MiUser, noteId: MiNote['id']) {
// Fetch unpinee
const note = await this.notesRepository.findOneBy({
id: noteId,
@@ -106,22 +106,19 @@ export class NotePiningService {
// Deliver to remote followers
if (this.userEntityService.isLocalUser(user) && !note.localOnly && ['public', 'home'].includes(note.visibility)) {
- this.deliverPinnedChange(user.id, noteId, false);
+ this.deliverPinnedChange(user, noteId, false);
}
}
@bindThis
- public async deliverPinnedChange(userId: MiUser['id'], noteId: MiNote['id'], isAddition: boolean) {
- const user = await this.usersRepository.findOneBy({ id: userId });
- if (user == null) throw new Error('user not found');
-
+ public async deliverPinnedChange(user: MiUser, noteId: MiNote['id'], isAddition: boolean) {
if (!this.userEntityService.isLocalUser(user)) return;
const target = `${this.config.url}/users/${user.id}/collections/featured`;
const item = `${this.config.url}/notes/${noteId}`;
const content = this.apRendererService.addContext(isAddition ? this.apRendererService.renderAdd(user, target, item) : this.apRendererService.renderRemove(user, target, item));
- this.apDeliverManagerService.deliverToFollowers(user, content);
- this.relayService.deliverToRelays(user, content);
+ await this.apDeliverManagerService.deliverToFollowers(user, content);
+ await this.relayService.deliverToRelays(user, content);
}
}