This commit is contained in:
mattyatea 2024-05-16 01:50:40 +09:00
parent ed14ddad0c
commit 4a0138297e
7 changed files with 29 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "misskey", "name": "misskey",
"version": "2024.5.0-beta1-mattyatea1", "version": "2024.5.0-beta1-mattyatea2",
"codename": "nasubi", "codename": "nasubi",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,9 +1,11 @@
import {Column} from "typeorm";
export class Loginbonus1715787239605 { export class Loginbonus1715787239605 {
name = 'Loginbonus1715787239605' name = 'Loginbonus1715787239605'
async up(queryRunner) { async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" ADD "getPoints" integer NOT NULL DEFAULT '0'`); } await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "getPoints"`); }
async down(queryRunner) { async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "getPoints"`); } await queryRunner.query(`ALTER TABLE "user_profile" ADD "getPoints" integer NOT NULL DEFAULT '0'`); }
} }

View File

@ -0,0 +1,13 @@
export class Loginbonus11715791271605 {
name = 'Loginbonus11715791271605'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "getPoints"`);
await queryRunner.query(`ALTER TABLE "user" ADD "getPoints" integer NOT NULL DEFAULT '0'`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "getPoints"`);
await queryRunner.query(`ALTER TABLE "user_profile" ADD "getPoints" integer NOT NULL DEFAULT '0'`);
}
}

View File

@ -471,9 +471,8 @@ export class UserEntityService implements OnModuleInit {
createdAt: this.idService.parse(announcement.id).date.toISOString(), createdAt: this.idService.parse(announcement.id).date.toISOString(),
...announcement, ...announcement,
})) : null; })) : null;
console.log(user.getPoints);
const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null; const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null;
const packed = { const packed = {
id: user.id, id: user.id,
name: user.name, name: user.name,

View File

@ -25,6 +25,11 @@ export class MiUser {
}) })
public lastFetchedAt: Date | null; public lastFetchedAt: Date | null;
@Column('integer', {
default: '0',
})
public getPoints: number;
@Index() @Index()
@Column('timestamp with time zone', { @Column('timestamp with time zone', {
nullable: true, nullable: true,

View File

@ -261,10 +261,6 @@ export class MiUserProfile {
length: 32, array: true, default: '{}', length: 32, array: true, default: '{}',
}) })
public loggedInDates: string[]; public loggedInDates: string[];
@Column('integer', {
default: '0',
})
public getPoints: number;
@Column('jsonb', { @Column('jsonb', {
default: [], default: [],

View File

@ -4,7 +4,7 @@
*/ */
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import type { UserProfilesRepository } from '@/models/_.js'; import type { UserProfilesRepository, UsersRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
@ -44,6 +44,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
constructor( constructor(
@Inject(DI.userProfilesRepository) @Inject(DI.userProfilesRepository)
private userProfilesRepository: UserProfilesRepository, private userProfilesRepository: UserProfilesRepository,
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
private notificationService: NotificationService, private notificationService: NotificationService,
private userEntityService: UserEntityService, private userEntityService: UserEntityService,
) { ) {
@ -70,7 +73,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
this.userProfilesRepository.update({ userId: user.id }, { this.userProfilesRepository.update({ userId: user.id }, {
loggedInDates: [...userProfile.loggedInDates, today], loggedInDates: [...userProfile.loggedInDates, today],
}); });
this.userProfilesRepository.update({ userId: user.id }, { this.usersRepository.update({ userId: user.id }, {
getPoints: userProfile.getPoints + todayGetPoints, getPoints: userProfile.getPoints + todayGetPoints,
}); });
this.notificationService.createNotification(user.id, 'loginbonus', { this.notificationService.createNotification(user.id, 'loginbonus', {