Skip to content

Commit

Permalink
Fix: Googleアナリティクスを使用できるように
Browse files Browse the repository at this point in the history
Feat: ログインボーナスのボーナスの名前を決められるように
  • Loading branch information
mattyatea committed Jul 26, 2024
1 parent 6b7b3b2 commit 6122ef4
Show file tree
Hide file tree
Showing 10 changed files with 1,119 additions and 458 deletions.
6 changes: 5 additions & 1 deletion locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export interface Locale extends ILocale {
*/
"followers": string;
/**
* プリズム
* ポイント
*/
"points": string;
/**
Expand Down Expand Up @@ -8748,6 +8748,10 @@ export interface Locale extends ILocale {
*/
"birthdayFollowings": string;
};
/**
* {getPoint}{pointName}ゲットしました!
*/
"nPointGets": ParameterizedString<"getPoint" | "pointName">;
"_cw": {
/**
* 隠す
Expand Down
4 changes: 3 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ note: "ノート"
notes: "ノート"
following: "フォロー"
followers: "フォロワー"
points: "プリズム"
points: "ポイント"
followsYou: "フォローされています"
createList: "リスト作成"
manageLists: "リストの管理"
Expand Down Expand Up @@ -2297,6 +2297,8 @@ _widgets:
clicker: "クリッカー"
birthdayFollowings: "今日誕生日のユーザー"

nPointGets: "{getPoint}{pointName}ゲットしました!"
pointName: "ログインボーナスのポイントの名前"
_cw:
hide: "隠す"
show: "もっと見る"
Expand Down
45 changes: 27 additions & 18 deletions packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ export class MetaEntityService {
constructor(
@Inject(DI.config)
private config: Config,

@Inject(DI.adsRepository)
private adsRepository: AdsRepository,

private userEntityService: UserEntityService,
private metaService: MetaService,
private instanceActorService: InstanceActorService,
) { }
) {}

@bindThis
public async pack(meta?: MiMeta): Promise<Packed<'MetaLite'>> {
Expand All @@ -40,30 +38,36 @@ export class MetaEntityService {
instance = await this.metaService.fetch();
}

const ads = await this.adsRepository.createQueryBuilder('ads')
const ads = await this.adsRepository
.createQueryBuilder('ads')
.where('ads.expiresAt > :now', { now: new Date() })
.andWhere('ads.startsAt <= :now', { now: new Date() })
.andWhere(new Brackets(qb => {
// 曜日のビットフラグを確認する
qb.where('ads.dayOfWeek & :dayOfWeek > 0', { dayOfWeek: 1 << new Date().getDay() })
.orWhere('ads.dayOfWeek = 0');
}))
.andWhere(
new Brackets((qb) => {
// 曜日のビットフラグを確認する
qb.where('ads.dayOfWeek & :dayOfWeek > 0', {
dayOfWeek: 1 << new Date().getDay(),
}).orWhere('ads.dayOfWeek = 0');
}),
)
.getMany();

// クライアントの手間を減らすためあらかじめJSONに変換しておく
let defaultLightTheme = null;
let defaultDarkTheme = null;
if (instance.defaultLightTheme) {
try {
defaultLightTheme = JSON.stringify(JSON5.parse(instance.defaultLightTheme));
} catch (e) {
}
defaultLightTheme = JSON.stringify(
JSON5.parse(instance.defaultLightTheme),
);
} catch (e) {}
}
if (instance.defaultDarkTheme) {
try {
defaultDarkTheme = JSON.stringify(JSON5.parse(instance.defaultDarkTheme));
} catch (e) {
}
defaultDarkTheme = JSON.stringify(
JSON5.parse(instance.defaultDarkTheme),
);
} catch (e) {}
}

const packed: Packed<'MetaLite'> = {
Expand Down Expand Up @@ -113,7 +117,7 @@ export class MetaEntityService {
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
defaultLightTheme,
defaultDarkTheme,
ads: ads.map(ad => ({
ads: ads.map((ad) => ({
id: ad.id,
url: ad.url,
place: ad.place,
Expand All @@ -124,6 +128,7 @@ export class MetaEntityService {
notesPerOneAd: instance.notesPerOneAd,
enableEmail: instance.enableEmail,
enableServiceWorker: instance.enableServiceWorker,
pointName: instance.pointName,

translatorAvailable: instance.deeplAuthKey != null,

Expand All @@ -148,13 +153,17 @@ export class MetaEntityService {

const packed = await this.pack(instance);

const proxyAccount = instance.proxyAccountId ? await this.userEntityService.pack(instance.proxyAccountId).catch(() => null) : null;
const proxyAccount = instance.proxyAccountId
? await this.userEntityService
.pack(instance.proxyAccountId)
.catch(() => null)
: null;

const packDetailed: Packed<'MetaDetailed'> = {
...packed,
cacheRemoteFiles: instance.cacheRemoteFiles,
cacheRemoteSensitiveFiles: instance.cacheRemoteSensitiveFiles,
requireSetup: !await this.instanceActorService.realLocalUsersPresent(),
requireSetup: !(await this.instanceActorService.realLocalUsersPresent()),
proxyAccountName: proxyAccount ? proxyAccount.username : null,
features: {
localTimeline: instance.policies.ltlAvailable,
Expand Down
67 changes: 50 additions & 17 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
import { id } from './util/id.js';
import { MiUser } from './User.js';

Expand All @@ -16,33 +16,38 @@ export class MiMeta {
public id: string;

@Column('varchar', {
length: 1024, nullable: true,
length: 1024,
nullable: true,
})
public name: string | null;

@Column('varchar', {
length: 64, nullable: true,
length: 64,
nullable: true,
})
public shortName: string | null;

@Column('varchar', {
length: 1024, nullable: true,
length: 1024,
nullable: true,
})
public description: string | null;

/**
* メンテナの名前
*/
@Column('varchar', {
length: 1024, nullable: true,
length: 1024,
nullable: true,
})
public maintainerName: string | null;

/**
* メンテナの連絡先
*/
@Column('varchar', {
length: 1024, nullable: true,
length: 1024,
nullable: true,
})
public maintainerEmail: string | null;

Expand All @@ -52,37 +57,51 @@ export class MiMeta {
public disableRegistration: boolean;

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public langs: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public pinnedUsers: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public hiddenTags: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public blockedHosts: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public sensitiveWords: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public prohibitedWords: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
length: 1024,
array: true,
default: '{}',
})
public silencedHosts: string[];

Expand Down Expand Up @@ -173,7 +192,7 @@ export class MiMeta {
})
public proxyAccountId: MiUser['id'] | null;

@ManyToOne(type => MiUser, {
@ManyToOne((type) => MiUser, {
onDelete: 'SET NULL',
})
@JoinColumn()
Expand Down Expand Up @@ -292,7 +311,12 @@ export class MiMeta {
enum: ['medium', 'low', 'high', 'veryLow', 'veryHigh'],
default: 'medium',
})
public sensitiveMediaDetectionSensitivity: 'medium' | 'low' | 'high' | 'veryLow' | 'veryHigh';
public sensitiveMediaDetectionSensitivity:
| 'medium'
| 'low'
| 'high'
| 'veryLow'
| 'veryHigh';

@Column('boolean', {
default: false,
Expand Down Expand Up @@ -348,6 +372,12 @@ export class MiMeta {
})
public enableServiceWorker: boolean;

@Column('varchar', {
length: 1024,
nullable: true,
})
public pointName: string | null;

@Column('varchar', {
length: 1024,
nullable: true,
Expand Down Expand Up @@ -576,7 +606,7 @@ export class MiMeta {
public enableIdenticonGeneration: boolean;

@Column('jsonb', {
default: { },
default: {},
})
public policies: Record<string, any>;

Expand All @@ -601,7 +631,10 @@ export class MiMeta {
public bannedEmailDomains: string[];

@Column('varchar', {
length: 1024, array: true, default: '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }',
length: 1024,
array: true,
default:
'{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }',
})
public preservedUsernames: string[];

Expand Down
Loading

0 comments on commit 6122ef4

Please sign in to comment.