6277a5545c
* wip * wip * wip * wip * wip * wip * Update NoteCreateService.ts * wip * wip * wip * wip * Update NoteCreateService.ts * wip * Update NoteCreateService.ts * wip * Update user-notes.ts * wip * wip * wip * Update NoteCreateService.ts * wip * Update timeline.ts * Update timeline.ts * Update timeline.ts * Update timeline.ts * Update timeline.ts * wip * Update timelines.ts * Update timelines.ts * Update timelines.ts * wip * wip * wip * Update timelines.ts * Update misskey-js.api.md * Update timelines.ts * Update timelines.ts * wip * wip * wip * Update timelines.ts * wip * Update timelines.ts * wip * test * Update activitypub.ts * refactor: UserListJoining -> UserListMembership * Update NoteCreateService.ts * wip
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import type { FollowingsRepository, UsersRepository } from '@/models/_.js';
|
|
import type { MiUser } from '@/models/User.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { bindThis } from '@/decorators.js';
|
|
|
|
@Injectable()
|
|
export class UserService {
|
|
constructor(
|
|
@Inject(DI.usersRepository)
|
|
private usersRepository: UsersRepository,
|
|
|
|
@Inject(DI.followingsRepository)
|
|
private followingsRepository: FollowingsRepository,
|
|
) {
|
|
}
|
|
|
|
@bindThis
|
|
public async updateLastActiveDate(user: MiUser): Promise<void> {
|
|
if (user.isHibernated) {
|
|
const result = await this.usersRepository.createQueryBuilder().update()
|
|
.set({
|
|
lastActiveDate: new Date(),
|
|
})
|
|
.where('id = :id', { id: user.id })
|
|
.returning('*')
|
|
.execute()
|
|
.then((response) => {
|
|
return response.raw[0];
|
|
});
|
|
const wokeUp = result.isHibernated;
|
|
if (wokeUp) {
|
|
this.usersRepository.update(user.id, {
|
|
isHibernated: false,
|
|
});
|
|
this.followingsRepository.update({
|
|
followerId: user.id,
|
|
}, {
|
|
isFollowerHibernated: false,
|
|
});
|
|
}
|
|
} else {
|
|
this.usersRepository.update(user.id, {
|
|
lastActiveDate: new Date(),
|
|
});
|
|
}
|
|
}
|
|
}
|