Merge branch 'develop'

This commit is contained in:
syuilo 2019-05-03 18:58:54 +09:00
commit 12cd2709d6
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
24 changed files with 133 additions and 119 deletions

View file

@ -1,5 +1,5 @@
<template>
<x-draggable tag="div" :list="blocks" handle=".drag-handle" :group="{ name: 'blocks' }" animation="150">
<x-draggable tag="div" :list="blocks" handle=".drag-handle" :group="{ name: 'blocks' }" animation="150" swap-threshold="0.5">
<component v-for="block in blocks" :is="'x-' + block.type" :value="block" @input="updateItem" @remove="removeItem" :key="block.id" :ai-script="aiScript"/>
</x-draggable>
</template>

View file

@ -1,12 +1,15 @@
<template>
<div class="cpjygsrt" :class="{ error: error != null, warn: warn != null, draggable }">
<header class="drag-handle">
<div class="cpjygsrt" :class="{ error: error != null, warn: warn != null }">
<header>
<div class="title"><slot name="header"></slot></div>
<div class="buttons">
<slot name="func"></slot>
<button v-if="removable" @click="remove()">
<fa :icon="faTrashAlt"/>
</button>
<button v-if="draggable" class="drag-handle">
<fa :icon="faBars"/>
</button>
<button @click="toggleContent(!showBody)">
<template v-if="showBody"><fa icon="angle-up"/></template>
<template v-else><fa icon="angle-down"/></template>
@ -23,6 +26,7 @@
<script lang="ts">
import Vue from 'vue';
import { faBars } from '@fortawesome/free-solid-svg-icons';
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import i18n from '../../../../i18n';
@ -54,7 +58,7 @@ export default Vue.extend({
data() {
return {
showBody: this.expanded,
faTrashAlt
faTrashAlt, faBars
};
},
methods: {
@ -124,9 +128,8 @@ export default Vue.extend({
&:active
color var(--faceTextButtonActive)
&.draggable
> header
cursor move
.drag-handle
cursor move
> .warn
color #b19e49

View file

@ -290,12 +290,17 @@ export default Vue.extend({
this.exportTarget == 'mute' ? 'i/export-mute' :
this.exportTarget == 'blocking' ? 'i/export-blocking' :
this.exportTarget == 'user-lists' ? 'i/export-user-lists' :
null, {});
this.$root.dialog({
type: 'info',
text: this.$t('export-requested')
});
null, {}).then(() => {
this.$root.dialog({
type: 'info',
text: this.$t('export-requested')
});
}).catch((e: any) => {
this.$root.dialog({
type: 'error',
text: e.message
});
});
},
doImport() {

View file

@ -173,9 +173,10 @@ export default class MiOS extends EventEmitter {
// Init service worker
if (this.shouldRegisterSw) {
this.getMeta().then(data => {
this.registerSw(data.swPublickey);
});
// #4813
//this.getMeta().then(data => {
// this.registerSw(data.swPublickey);
//});
}
};

View file

@ -3,12 +3,6 @@
*/
import composeNotification from './common/scripts/compose-notification';
import { erase } from '../../prelude/array';
// キャッシュするリソース
const cachee = [
'/'
];
// インストールされたとき
self.addEventListener('install', ev => {
@ -16,31 +10,9 @@ self.addEventListener('install', ev => {
ev.waitUntil(Promise.all([
self.skipWaiting(), // Force activate
caches.open(_VERSION_).then(cache => cache.addAll(cachee)) // Cache
]));
});
// アクティベートされたとき
self.addEventListener('activate', ev => {
// Clean up old caches
ev.waitUntil(
caches.keys().then(keys => Promise.all(
erase(_VERSION_, keys)
.map(key => caches.delete(key))
))
);
});
// リクエストが発生したとき
self.addEventListener('fetch', ev => {
ev.respondWith(
// キャッシュがあるか確認してあればそれを返す
caches.match(ev.request).then(response =>
response || fetch(ev.request)
)
);
});
// プッシュ通知を受け取ったとき
self.addEventListener('push', ev => {
// クライアント取得
@ -59,11 +31,3 @@ self.addEventListener('push', ev => {
});
}));
});
self.addEventListener('message', ev => {
if (ev.data == 'clear') {
caches.keys().then(keys => {
for (const key of keys) caches.delete(key);
});
}
});

View file

@ -160,6 +160,7 @@ export class ASEvaluator {
subtract: (a: number, b: number) => a - b,
multiply: (a: number, b: number) => a * b,
divide: (a: number, b: number) => a / b,
remind: (a: number, b: number) => a % b,
strLen: (a: string) => a.length,
strPick: (a: string, b: number) => a[b - 1],
strReplace: (a: string, b: string, c: string) => a.split(b).join(c),

View file

@ -57,6 +57,7 @@ export const funcDefs: Record<string, { in: any[]; out: any; category: string; i
subtract: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faMinus, },
multiply: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faTimes, },
divide: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faDivide, },
remind: { in: ['number', 'number'], out: 'number', category: 'operation', icon: faDivide, },
eq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: faEquals, },
notEq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: faNotEqual, },
gt: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: faGreaterThan, },

View file

@ -144,10 +144,10 @@ export class UserProfile {
})
public githubAccessToken: string | null;
@Column('integer', {
nullable: true, default: null,
@Column('varchar', {
length: 64, nullable: true, default: null,
})
public githubId: number | null;
public githubId: string | null;
@Column('varchar', {
length: 64, nullable: true, default: null,
@ -169,10 +169,10 @@ export class UserProfile {
})
public discordRefreshToken: string | null;
@Column('integer', {
nullable: true, default: null,
@Column('varchar', {
length: 64, nullable: true, default: null,
})
public discordExpiresDate: number | null;
public discordExpiresDate: string | null;
@Column('varchar', {
length: 64, nullable: true, default: null,

View file

@ -127,6 +127,7 @@ export class UserRepository extends Repository<User> {
pinnedNotes: Notes.packMany(pins.map(pin => pin.noteId), meId, {
detail: true
}),
twoFactorEnabled: profile!.twoFactorEnabled,
} : {}),
...(opts.detail && meId === user.id ? {
@ -135,7 +136,6 @@ export class UserRepository extends Repository<User> {
autoWatch: profile!.autoWatch,
alwaysMarkNsfw: profile!.alwaysMarkNsfw,
carefulBot: profile!.carefulBot,
twoFactorEnabled: profile!.twoFactorEnabled,
hasUnreadMessagingMessage: MessagingMessages.count({
where: {
recipientId: user.id,

View file

@ -85,7 +85,7 @@ export async function exportBlocking(job: Bull.Job, done: any): Promise<void> {
logger.succ(`Exported to: ${path}`);
const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
const driveFile = await addFile(user, path, fileName);
const driveFile = await addFile(user, path, fileName, null, null, true);
logger.succ(`Exported to: ${driveFile.id}`);
cleanup();

View file

@ -85,7 +85,7 @@ export async function exportFollowing(job: Bull.Job, done: any): Promise<void> {
logger.succ(`Exported to: ${path}`);
const fileName = 'following-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
const driveFile = await addFile(user, path, fileName);
const driveFile = await addFile(user, path, fileName, null, null, true);
logger.succ(`Exported to: ${driveFile.id}`);
cleanup();

View file

@ -85,7 +85,7 @@ export async function exportMute(job: Bull.Job, done: any): Promise<void> {
logger.succ(`Exported to: ${path}`);
const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
const driveFile = await addFile(user, path, fileName);
const driveFile = await addFile(user, path, fileName, null, null, true);
logger.succ(`Exported to: ${driveFile.id}`);
cleanup();

View file

@ -108,7 +108,7 @@ export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
logger.succ(`Exported to: ${path}`);
const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.json';
const driveFile = await addFile(user, path, fileName);
const driveFile = await addFile(user, path, fileName, null, null, true);
logger.succ(`Exported to: ${driveFile.id}`);
cleanup();

View file

@ -62,7 +62,7 @@ export async function exportUserLists(job: Bull.Job, done: any): Promise<void> {
logger.succ(`Exported to: ${path}`);
const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
const driveFile = await addFile(user, path, fileName);
const driveFile = await addFile(user, path, fileName, null, null, true);
logger.succ(`Exported to: ${driveFile.id}`);
cleanup();

View file

@ -35,7 +35,8 @@ export async function importFollowing(job: Bull.Job, done: any): Promise<void> {
linenum++;
try {
const { username, host } = parseAcct(line.trim());
const acct = line.split(',')[0].trim();
const { username, host } = parseAcct(acct);
let target = isSelfHost(host!) ? await Users.findOne({
host: null,

View file

@ -203,12 +203,8 @@ router.get('/dc/cb', async ctx => {
}
const profile = await UserProfiles.createQueryBuilder()
.where('discord @> :discord', {
discord: {
id: id,
},
})
.andWhere('userHost IS NULL')
.where('"discordId" = :id', { id: id })
.andWhere('"userHost" IS NULL')
.getOne();
if (profile == null) {

View file

@ -193,12 +193,8 @@ router.get('/gh/cb', async ctx => {
}
const link = await UserProfiles.createQueryBuilder()
.where('github @> :github', {
github: {
id: id,
},
})
.andWhere('userHost IS NULL')
.where('"githubId" = :id', { id: id })
.andWhere('"userHost" IS NULL')
.getOne();
if (link == null) {

View file

@ -141,12 +141,8 @@ router.get('/tw/cb', async ctx => {
const result = await twAuth!.done(JSON.parse(twCtx), ctx.query.oauth_verifier);
const link = await UserProfiles.createQueryBuilder()
.where('twitter @> :twitter', {
twitter: {
userId: result.userId,
},
})
.andWhere('userHost IS NULL')
.where('"twitterUserId" = :id', { id: result.userId })
.andWhere('"userHost" IS NULL')
.getOne();
if (link == null) {

View file

@ -393,6 +393,8 @@ export default async function(
if (isLink) {
file.url = url;
file.thumbnailUrl = url;
file.webpublicUrl = url;
}
}