replace shared_access_token table with an extra column on access_token
This commit is contained in:
parent
e5cf9d3f9a
commit
49dad22609
12 changed files with 111 additions and 147 deletions
|
|
@ -97,4 +97,18 @@ export class MiAccessToken {
|
|||
comment: 'Limits the user\' rank (user, moderator, or admin) when using this token. If null (default), then uses the user\'s actual rank.',
|
||||
})
|
||||
public rank: AccessTokenRank | null;
|
||||
|
||||
@Index('IDX_access_token_granteeIds', { synchronize: false })
|
||||
@Column({
|
||||
...id(),
|
||||
array: true, default: '{}',
|
||||
comment: 'IDs of other users who are permitted to access and use this token.',
|
||||
})
|
||||
public granteeIds: string[];
|
||||
|
||||
public constructor(props?: Partial<MiAccessToken>) {
|
||||
if (props) {
|
||||
Object.assign(this, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ import {
|
|||
SkApContext,
|
||||
SkApFetchLog,
|
||||
SkApInboxLog,
|
||||
SkSharedAccessToken,
|
||||
} from './_.js';
|
||||
import type { Provider } from '@nestjs/common';
|
||||
import type { DataSource } from 'typeorm';
|
||||
|
|
@ -153,12 +152,6 @@ const $apInboxLogsRepository: Provider = {
|
|||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $skSharedAccessToken: Provider = {
|
||||
provide: DI.sharedAccessTokensRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(SkSharedAccessToken).extend(miRepository as MiRepository<SkSharedAccessToken>),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $noteFavoritesRepository: Provider = {
|
||||
provide: DI.noteFavoritesRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(MiNoteFavorite).extend(miRepository as MiRepository<MiNoteFavorite>),
|
||||
|
|
@ -592,7 +585,6 @@ const $noteScheduleRepository: Provider = {
|
|||
$apContextRepository,
|
||||
$apFetchLogsRepository,
|
||||
$apInboxLogsRepository,
|
||||
$skSharedAccessToken,
|
||||
$noteFavoritesRepository,
|
||||
$noteThreadMutingsRepository,
|
||||
$noteReactionsRepository,
|
||||
|
|
@ -675,7 +667,6 @@ const $noteScheduleRepository: Provider = {
|
|||
$apContextRepository,
|
||||
$apFetchLogsRepository,
|
||||
$apInboxLogsRepository,
|
||||
$skSharedAccessToken,
|
||||
$noteFavoritesRepository,
|
||||
$noteThreadMutingsRepository,
|
||||
$noteReactionsRepository,
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||
import { id } from '@/models/util/id.js';
|
||||
import { MiUser } from '@/models/User.js';
|
||||
import { MiAccessToken } from '@/models/AccessToken.js';
|
||||
|
||||
@Entity('shared_access_token')
|
||||
export class SkSharedAccessToken {
|
||||
@PrimaryColumn({
|
||||
...id(),
|
||||
comment: 'ID of the access token that is shared',
|
||||
})
|
||||
public accessTokenId: string;
|
||||
|
||||
@ManyToOne(() => MiAccessToken, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'accessTokenId',
|
||||
referencedColumnName: 'id',
|
||||
foreignKeyConstraintName: 'FK_shared_access_token_accessTokenId',
|
||||
})
|
||||
public accessToken: MiAccessToken;
|
||||
|
||||
@Index('IDX_shared_access_token_granteeId')
|
||||
@Column({
|
||||
...id(),
|
||||
comment: 'ID of the user who is allowed to use this access token',
|
||||
})
|
||||
public granteeId: string;
|
||||
|
||||
@ManyToOne(() => MiUser, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'granteeId',
|
||||
referencedColumnName: 'id',
|
||||
foreignKeyConstraintName: 'FK_shared_access_token_granteeId',
|
||||
})
|
||||
public grantee?: MiUser;
|
||||
|
||||
constructor(props?: Partial<SkSharedAccessToken>) {
|
||||
if (props) {
|
||||
Object.assign(this, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,6 @@ import { SkApInboxLog } from '@/models/SkApInboxLog.js';
|
|||
import { SkApFetchLog } from '@/models/SkApFetchLog.js';
|
||||
import { SkApContext } from '@/models/SkApContext.js';
|
||||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import { SkSharedAccessToken } from '@/models/SkSharedAccessToken.js';
|
||||
|
||||
export interface MiRepository<T extends ObjectLiteral> {
|
||||
createTableColumnNames(this: Repository<T> & MiRepository<T>): string[];
|
||||
|
|
@ -169,7 +168,6 @@ export {
|
|||
SkApContext,
|
||||
SkApFetchLog,
|
||||
SkApInboxLog,
|
||||
SkSharedAccessToken,
|
||||
MiAbuseUserReport,
|
||||
MiAbuseReportNotificationRecipient,
|
||||
MiAccessToken,
|
||||
|
|
@ -330,4 +328,3 @@ export type BubbleGameRecordsRepository = Repository<MiBubbleGameRecord> & MiRep
|
|||
export type ReversiGamesRepository = Repository<MiReversiGame> & MiRepository<MiReversiGame>;
|
||||
export type NoteEditRepository = Repository<NoteEdit> & MiRepository<NoteEdit>;
|
||||
export type NoteScheduleRepository = Repository<MiNoteSchedule> & MiRepository<MiNoteSchedule>;
|
||||
export type SharedAccessTokensRepository = Repository<SkSharedAccessToken> & MiRepository<SkSharedAccessToken>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue