(fix) タイムゾーンによっては誕生日のフォロー中ユーザーが正しく読み込まれない

This commit is contained in:
kakkokari-gtyih 2023-12-28 16:56:17 +09:00
parent 7ca0af9e7e
commit 9ce9a5c6f0
7 changed files with 11 additions and 14 deletions

View File

@ -6,6 +6,7 @@
import { IsNull } from 'typeorm'; import { IsNull } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import type { UsersRepository, FollowingsRepository, UserProfilesRepository } from '@/models/_.js'; import type { UsersRepository, FollowingsRepository, UserProfilesRepository } from '@/models/_.js';
import { birthdaySchema } from '@/models/User.js';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import { QueryService } from '@/core/QueryService.js'; import { QueryService } from '@/core/QueryService.js';
import { FollowingEntityService } from '@/core/entities/FollowingEntityService.js'; import { FollowingEntityService } from '@/core/entities/FollowingEntityService.js';
@ -66,7 +67,7 @@ export const paramDef = {
description: 'The local host is represented with `null`.', description: 'The local host is represented with `null`.',
}, },
birthday: { type: 'string', nullable: true }, birthday: { ...birthdaySchema, nullable: true },
}, },
anyOf: [ anyOf: [
{ required: ['userId'] }, { required: ['userId'] },
@ -127,9 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.birthday) { if (ps.birthday) {
try { try {
const d = new Date(ps.birthday); const birthday = ps.birthday.substring(5, 10);
d.setHours(0, 0, 0, 0);
const birthday = `${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile'); const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile');
birthdayUserQuery.select('user_profile.userId') birthdayUserQuery.select('user_profile.userId')
.where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`); .where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`);

View File

@ -53,7 +53,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit, emit,
); );
const users = ref<Misskey.entities.FollowingFolloweePopulated[]>([]); const users = ref<Misskey.Endpoints['users/following']['res']>([]);
const fetching = ref(true); const fetching = ref(true);
let lastFetchedAt = '1970-01-01'; let lastFetchedAt = '1970-01-01';
@ -70,9 +70,10 @@ const fetch = () => {
now.setHours(0, 0, 0, 0); now.setHours(0, 0, 0, 0);
if (now > lfAtD) { if (now > lfAtD) {
fetching.value = true;
os.api('users/following', { os.api('users/following', {
limit: 18, limit: 18,
birthday: now.toISOString(), birthday: `${now.getFullYear().toString().padStart(4, '0')}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`,
userId: $i.id, userId: $i.id,
}).then(res => { }).then(res => {
users.value = res; users.value = res;

View File

@ -1,6 +1,6 @@
/* /*
* version: 2023.12.0 * version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.494Z * generatedAt: 2023-12-28T07:43:32.686Z
*/ */
import type { SwitchCaseResponseType } from '../api.js'; import type { SwitchCaseResponseType } from '../api.js';
@ -33,7 +33,6 @@ declare module '../api.js' {
/** /**
* No description provided. * No description provided.
* *
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *No* * **Credential required**: *No*
*/ */
request<E extends 'admin/accounts/create', P extends Endpoints[E]['req']>( request<E extends 'admin/accounts/create', P extends Endpoints[E]['req']>(

View File

@ -1,6 +1,6 @@
/* /*
* version: 2023.12.0 * version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.491Z * generatedAt: 2023-12-28T07:43:32.682Z
*/ */
import type { import type {

View File

@ -1,6 +1,6 @@
/* /*
* version: 2023.12.0 * version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.489Z * generatedAt: 2023-12-28T07:43:32.680Z
*/ */
import { operations } from './types.js'; import { operations } from './types.js';

View File

@ -1,6 +1,6 @@
/* /*
* version: 2023.12.0 * version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.485Z * generatedAt: 2023-12-28T07:43:32.679Z
*/ */
import { components } from './types.js'; import { components } from './types.js';

View File

@ -3,7 +3,7 @@
/* /*
* version: 2023.12.0 * version: 2023.12.0
* generatedAt: 2023-12-26T23:35:09.389Z * generatedAt: 2023-12-28T07:43:32.546Z
*/ */
/** /**
@ -40,7 +40,6 @@ export type paths = {
* admin/accounts/create * admin/accounts/create
* @description No description provided. * @description No description provided.
* *
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *No* * **Credential required**: *No*
*/ */
post: operations['admin/accounts/create']; post: operations['admin/accounts/create'];
@ -4620,7 +4619,6 @@ export type operations = {
* admin/accounts/create * admin/accounts/create
* @description No description provided. * @description No description provided.
* *
* **Internal Endpoint**: This endpoint is an API for the misskey mainframe and is not intended for use by third parties.
* **Credential required**: *No* * **Credential required**: *No*
*/ */
'admin/accounts/create': { 'admin/accounts/create': {