@@ -106,7 +107,10 @@ export default Vue.extend({
methods: {
hint() {
- alert(this.$t('widgets-hints'));
+ this.$root.dialog({
+ type: 'info',
+ text: this.$t('widgets-hints')
+ });
},
widgetFunc(id) {
diff --git a/src/client/style.styl b/src/client/style.styl
index c6a8e4f19..968e66e75 100644
--- a/src/client/style.styl
+++ b/src/client/style.styl
@@ -1,4 +1,4 @@
-@charset 'utf-8'
+@charset "utf-8"
/*
::selection
diff --git a/src/docs/stream.ja-JP.md b/src/docs/stream.ja-JP.md
index 0e9afa733..40fc49916 100644
--- a/src/docs/stream.ja-JP.md
+++ b/src/docs/stream.ja-JP.md
@@ -130,10 +130,12 @@ Misskeyのストリームに接続しただけでは、まだリアルタイム
```json
{
type: 'api',
- id: 'xxxxxxxxxxxxxxxx',
- endpoint: 'notes/create',
- data: {
- text: 'yee haw!'
+ body: {
+ id: 'xxxxxxxxxxxxxxxx',
+ endpoint: 'notes/create',
+ data: {
+ text: 'yee haw!'
+ }
}
}
```
diff --git a/src/misc/fetch-meta.ts b/src/misc/fetch-meta.ts
index cf1fc474c..800f0b9e6 100644
--- a/src/misc/fetch-meta.ts
+++ b/src/misc/fetch-meta.ts
@@ -1,14 +1,21 @@
import { Meta } from '../models/entities/meta';
-import { Metas } from '../models';
-import { genId } from './gen-id';
+import { getConnection } from 'typeorm';
export default async function(): Promise {
- const meta = await Metas.findOne();
- if (meta) {
- return meta;
- } else {
- return Metas.save({
- id: genId(),
- } as Meta);
- }
+ return await getConnection().transaction(async transactionalEntityManager => {
+ // バグでレコードが複数出来てしまっている可能性があるので新しいIDを優先する
+ const meta = await transactionalEntityManager.findOne(Meta, {
+ order: {
+ id: 'DESC'
+ }
+ });
+
+ if (meta) {
+ return meta;
+ } else {
+ return await transactionalEntityManager.save(Meta, {
+ id: 'x'
+ }) as Meta;
+ }
+ });
}
diff --git a/src/models/entities/meta.ts b/src/models/entities/meta.ts
index f3ac23bac..be41cf358 100644
--- a/src/models/entities/meta.ts
+++ b/src/models/entities/meta.ts
@@ -1,9 +1,11 @@
import { Entity, Column, PrimaryColumn } from 'typeorm';
-import { id } from '../id';
@Entity()
export class Meta {
- @PrimaryColumn(id())
+ @PrimaryColumn({
+ type: 'varchar',
+ length: 32
+ })
public id: string;
@Column('varchar', {
diff --git a/src/models/entities/note.ts b/src/models/entities/note.ts
index 969363da3..b71c02234 100644
--- a/src/models/entities/note.ts
+++ b/src/models/entities/note.ts
@@ -93,12 +93,12 @@ export class Note {
})
public localOnly: boolean;
- @Column('integer', {
+ @Column('smallint', {
default: 0
})
public renoteCount: number;
- @Column('integer', {
+ @Column('smallint', {
default: 0
})
public repliesCount: number;
@@ -129,12 +129,14 @@ export class Note {
})
public score: number;
+ @Index()
@Column({
...id(),
array: true, default: '{}'
})
public fileIds: DriveFile['id'][];
+ @Index()
@Column('varchar', {
length: 256, array: true, default: '{}'
})
diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts
index 7a48d24e1..98ed2bddc 100644
--- a/src/models/repositories/note.ts
+++ b/src/models/repositories/note.ts
@@ -103,7 +103,7 @@ export class NoteRepository extends Repository {
const host = note.userHost;
async function populatePoll() {
- const poll = await Polls.findOne({ noteId: note.id }).then(ensure);
+ const poll = await Polls.findOne(note.id).then(ensure);
const choices = poll.choices.map(c => ({
text: c,
votes: poll.votes[poll.choices.indexOf(c)],
diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts
index 9e4247545..30c77e78c 100644
--- a/src/models/repositories/user.ts
+++ b/src/models/repositories/user.ts
@@ -84,6 +84,8 @@ export class UserRepository extends Repository {
const pins = opts.detail ? await UserNotePinings.find({ userId: user.id }) : [];
const profile = opts.detail ? await UserProfiles.findOne({ userId: user.id }).then(ensure) : null;
+ const falsy = opts.detail ? false : undefined;
+
return await rap({
id: user.id,
name: user.name,
@@ -91,10 +93,10 @@ export class UserRepository extends Repository {
host: user.host,
avatarUrl: user.avatarUrl ? user.avatarUrl : config.url + '/avatar/' + user.id,
avatarColor: user.avatarColor,
- isAdmin: user.isAdmin || undefined,
- isBot: user.isBot || undefined,
- isCat: user.isCat || undefined,
- isVerified: user.isVerified || undefined,
+ isAdmin: user.isAdmin || falsy,
+ isBot: user.isBot || falsy,
+ isCat: user.isCat || falsy,
+ isVerified: user.isVerified || falsy,
// カスタム絵文字添付
emojis: user.emojis.length > 0 ? Emojis.find({
@@ -123,7 +125,7 @@ export class UserRepository extends Repository {
bannerUrl: user.bannerUrl,
bannerColor: user.bannerColor,
isLocked: user.isLocked,
- isModerator: user.isModerator || undefined,
+ isModerator: user.isModerator || falsy,
description: profile!.description,
location: profile!.location,
birthday: profile!.birthday,
diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts
index e242ac71a..3c6380acb 100644
--- a/src/server/api/endpoints/admin/update-meta.ts
+++ b/src/server/api/endpoints/admin/update-meta.ts
@@ -1,6 +1,6 @@
import $ from 'cafy';
import define from '../../define';
-import { Metas } from '../../../../models';
+import { getConnection } from 'typeorm';
import { Meta } from '../../../../models/entities/meta';
export const meta = {
@@ -505,11 +505,17 @@ export default define(meta, async (ps) => {
set.swPrivateKey = ps.swPrivateKey;
}
- const meta = await Metas.findOne();
+ await getConnection().transaction(async transactionalEntityManager => {
+ const meta = await transactionalEntityManager.findOne(Meta, {
+ order: {
+ id: 'DESC'
+ }
+ });
- if (meta) {
- await Metas.update(meta.id, set);
- } else {
- await Metas.save(set);
- }
+ if (meta) {
+ await transactionalEntityManager.update(Meta, meta.id, set);
+ } else {
+ await transactionalEntityManager.save(Meta, set);
+ }
+ });
});
diff --git a/src/services/chart/core.ts b/src/services/chart/core.ts
index 0a9ec8dae..fe762f2b2 100644
--- a/src/services/chart/core.ts
+++ b/src/services/chart/core.ts
@@ -79,7 +79,7 @@ export default abstract class Chart> {
flatColumns(v.properties, p);
} else {
columns[this.columnPrefix + p] = {
- type: 'integer',
+ type: 'bigint',
};
}
}
diff --git a/src/services/drive/delete-file.ts b/src/services/drive/delete-file.ts
index bba453b98..f1280822a 100644
--- a/src/services/drive/delete-file.ts
+++ b/src/services/drive/delete-file.ts
@@ -2,7 +2,7 @@ import * as Minio from 'minio';
import config from '../../config';
import { DriveFile } from '../../models/entities/drive-file';
import { InternalStorage } from './internal-storage';
-import { DriveFiles, Instances } from '../../models';
+import { DriveFiles, Instances, Notes } from '../../models';
import { driveChart, perUserDriveChart, instanceChart } from '../chart';
export default async function(file: DriveFile, isExpired = false) {
@@ -40,6 +40,11 @@ export default async function(file: DriveFile, isExpired = false) {
});
} else {
DriveFiles.delete(file.id);
+
+ // TODO: トランザクション
+ Notes.createQueryBuilder().delete()
+ .where(':id = ANY(fileIds)', { id: file.id })
+ .execute();
}
// 統計を更新