Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6e4a1770e | |||
31006507c0 | |||
9ca6a6bf06 | |||
afdacf14b7 | |||
5da18ba535 | |||
e6cc937ac2 | |||
87091a2e03 | |||
59d67d3140 | |||
7b4c307c46 | |||
92484be87f | |||
56b8f8b07d | |||
722de35037 | |||
d93f76c1af | |||
cba0dd5e17 | |||
a2e2d5ba77 |
@ -328,6 +328,7 @@ common/views/components/note-menu.vue:
|
|||||||
copy-link: "リンクをコピー"
|
copy-link: "リンクをコピー"
|
||||||
favorite: "お気に入り"
|
favorite: "お気に入り"
|
||||||
pin: "ピン留め"
|
pin: "ピン留め"
|
||||||
|
unpin: "ピン留め解除"
|
||||||
delete: "削除"
|
delete: "削除"
|
||||||
delete-confirm: "この投稿を削除しますか?"
|
delete-confirm: "この投稿を削除しますか?"
|
||||||
remote: "投稿元で見る"
|
remote: "投稿元で見る"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"author": "syuilo <i@syuilo.com>",
|
"author": "syuilo <i@syuilo.com>",
|
||||||
"version": "8.59.0",
|
"version": "8.62.0",
|
||||||
"clientVersion": "1.0.9949",
|
"clientVersion": "1.0.9964",
|
||||||
"codename": "nighthike",
|
"codename": "nighthike",
|
||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
@ -59,7 +59,7 @@ export default {
|
|||||||
|
|
||||||
el.dataset.reservedKeys = reservedKeys.map(key => `'${key}'`).join(' ');
|
el.dataset.reservedKeys = reservedKeys.map(key => `'${key}'`).join(' ');
|
||||||
|
|
||||||
el._keyHandler = e => {
|
el._keyHandler = (e: KeyboardEvent) => {
|
||||||
const key = e.code.toLowerCase();
|
const key = e.code.toLowerCase();
|
||||||
|
|
||||||
const targetReservedKeys = document.activeElement ? ((document.activeElement as any).dataset || {}).reservedKeys || '' : '';
|
const targetReservedKeys = document.activeElement ? ((document.activeElement as any).dataset || {}).reservedKeys || '' : '';
|
||||||
@ -72,7 +72,8 @@ export default {
|
|||||||
const matched = pattern.which.includes(key) &&
|
const matched = pattern.which.includes(key) &&
|
||||||
pattern.ctrl == e.ctrlKey &&
|
pattern.ctrl == e.ctrlKey &&
|
||||||
pattern.shift == e.shiftKey &&
|
pattern.shift == e.shiftKey &&
|
||||||
pattern.alt == e.altKey;
|
pattern.alt == e.altKey &&
|
||||||
|
e.metaKey == false;
|
||||||
|
|
||||||
if (matched) {
|
if (matched) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
require('fuckadblock');
|
|
||||||
|
|
||||||
declare const fuckAdBlock: any;
|
declare const fuckAdBlock: any;
|
||||||
|
|
||||||
export default (os) => {
|
export default (os) => {
|
||||||
|
require('fuckadblock');
|
||||||
|
|
||||||
function adBlockDetected() {
|
function adBlockDetected() {
|
||||||
os.apis.dialog({
|
os.apis.dialog({
|
||||||
title: '%fa:exclamation-triangle%%i18n:common.adblock.detected%',
|
title: '%fa:exclamation-triangle%%i18n:common.adblock.detected%',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
import instance from './instance.vue';
|
||||||
import cwButton from './cw-button.vue';
|
import cwButton from './cw-button.vue';
|
||||||
import tagCloud from './tag-cloud.vue';
|
import tagCloud from './tag-cloud.vue';
|
||||||
import trends from './trends.vue';
|
import trends from './trends.vue';
|
||||||
@ -43,6 +44,7 @@ import uiSelect from './ui/select.vue';
|
|||||||
import formButton from './ui/form/button.vue';
|
import formButton from './ui/form/button.vue';
|
||||||
import formRadio from './ui/form/radio.vue';
|
import formRadio from './ui/form/radio.vue';
|
||||||
|
|
||||||
|
Vue.component('mk-instance', instance);
|
||||||
Vue.component('mk-cw-button', cwButton);
|
Vue.component('mk-cw-button', cwButton);
|
||||||
Vue.component('mk-tag-cloud', tagCloud);
|
Vue.component('mk-tag-cloud', tagCloud);
|
||||||
Vue.component('mk-trends', trends);
|
Vue.component('mk-trends', trends);
|
||||||
|
57
src/client/app/common/views/components/instance.vue
Normal file
57
src/client/app/common/views/components/instance.vue
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<div class="nhasjydimbopojusarffqjyktglcuxjy" v-if="meta">
|
||||||
|
<div class="banner" :style="{ backgroundImage: meta.bannerUrl ? `url(${meta.bannerUrl})` : null }"></div>
|
||||||
|
|
||||||
|
<h1>{{ meta.name }}</h1>
|
||||||
|
<p v-html="meta.description || '%i18n:common.about%'"></p>
|
||||||
|
<router-link to="/">%i18n:@start%</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
meta: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
(this as any).os.getMeta().then(meta => {
|
||||||
|
this.meta = meta;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="stylus" scoped>
|
||||||
|
root(isDark)
|
||||||
|
color isDark ? #fff : #5b646f
|
||||||
|
background isDark ? #21242f : #fff
|
||||||
|
text-align center
|
||||||
|
|
||||||
|
> .banner
|
||||||
|
height 100px
|
||||||
|
background-position center
|
||||||
|
background-size cover
|
||||||
|
|
||||||
|
> h1
|
||||||
|
margin 16px
|
||||||
|
font-size 16px
|
||||||
|
|
||||||
|
> p
|
||||||
|
margin 16px
|
||||||
|
font-size 14px
|
||||||
|
|
||||||
|
> a
|
||||||
|
display block
|
||||||
|
padding-bottom 16px
|
||||||
|
|
||||||
|
.nhasjydimbopojusarffqjyktglcuxjy[data-darkmode]
|
||||||
|
root(true)
|
||||||
|
|
||||||
|
.nhasjydimbopojusarffqjyktglcuxjy:not([data-darkmode])
|
||||||
|
root(false)
|
||||||
|
|
||||||
|
</style>
|
@ -2,6 +2,8 @@
|
|||||||
<span class="mk-nav">
|
<span class="mk-nav">
|
||||||
<a :href="aboutUrl">%i18n:@about%</a>
|
<a :href="aboutUrl">%i18n:@about%</a>
|
||||||
<i>・</i>
|
<i>・</i>
|
||||||
|
<a href="/stats">%i18n:@stats%</a>
|
||||||
|
<i>・</i>
|
||||||
<a :href="repositoryUrl">%i18n:@repository%</a>
|
<a :href="repositoryUrl">%i18n:@repository%</a>
|
||||||
<i>・</i>
|
<i>・</i>
|
||||||
<a :href="feedbackUrl" target="_blank">%i18n:@feedback%</a>
|
<a :href="feedbackUrl" target="_blank">%i18n:@feedback%</a>
|
||||||
|
@ -28,12 +28,20 @@ export default Vue.extend({
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
if (this.note.userId == this.$store.state.i.id) {
|
if (this.note.userId == this.$store.state.i.id) {
|
||||||
|
if ((this.$store.state.i.pinnedNoteIds || []).includes(this.note.id)) {
|
||||||
|
items.push({
|
||||||
|
icon: '%fa:thumbtack%',
|
||||||
|
text: '%i18n:@unpin%',
|
||||||
|
action: this.unpin
|
||||||
|
});
|
||||||
|
} else {
|
||||||
items.push({
|
items.push({
|
||||||
icon: '%fa:thumbtack%',
|
icon: '%fa:thumbtack%',
|
||||||
text: '%i18n:@pin%',
|
text: '%i18n:@pin%',
|
||||||
action: this.pin
|
action: this.pin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
|
if (this.note.userId == this.$store.state.i.id || this.$store.state.i.isAdmin) {
|
||||||
items.push({
|
items.push({
|
||||||
@ -56,6 +64,7 @@ export default Vue.extend({
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
detail() {
|
detail() {
|
||||||
this.$router.push(`/notes/${ this.note.id }`);
|
this.$router.push(`/notes/${ this.note.id }`);
|
||||||
@ -73,6 +82,14 @@ export default Vue.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
unpin() {
|
||||||
|
(this as any).api('i/unpin', {
|
||||||
|
noteId: this.note.id
|
||||||
|
}).then(() => {
|
||||||
|
this.destroyDom();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
del() {
|
del() {
|
||||||
if (!window.confirm('%i18n:@delete-confirm%')) return;
|
if (!window.confirm('%i18n:@delete-confirm%')) return;
|
||||||
(this as any).api('notes/delete', {
|
(this as any).api('notes/delete', {
|
||||||
|
@ -87,10 +87,12 @@ init(async (launch) => {
|
|||||||
updateBanner: updateBanner(os)
|
updateBanner: updateBanner(os)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (os.store.getters.isSignedIn) {
|
||||||
/**
|
/**
|
||||||
* Fuck AD Block
|
* Fuck AD Block
|
||||||
*/
|
*/
|
||||||
fuckAdBlock(os);
|
fuckAdBlock(os);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Notification
|
* Init Notification
|
||||||
|
@ -360,8 +360,8 @@ root(isDark)
|
|||||||
|
|
||||||
> .form
|
> .form
|
||||||
margin-bottom 16px
|
margin-bottom 16px
|
||||||
border solid 1px rgba(#000, 0.075)
|
box-shadow var(--shadow)
|
||||||
border-radius 4px
|
border-radius var(--round)
|
||||||
|
|
||||||
@media (max-width 700px)
|
@media (max-width 700px)
|
||||||
padding 0
|
padding 0
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<x-timeline class="timeline" ref="tl" :user="user"/>
|
<x-timeline class="timeline" ref="tl" :user="user"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="side">
|
<div class="side">
|
||||||
|
<div class="instance" v-if="!$store.getters.isSignedIn"><mk-instance/></div>
|
||||||
<x-profile :user="user"/>
|
<x-profile :user="user"/>
|
||||||
<x-twitter :user="user" v-if="user.host === null && user.twitter"/>
|
<x-twitter :user="user" v-if="user.host === null && user.twitter"/>
|
||||||
<mk-calendar @chosen="warp" :start="new Date(user.createdAt)"/>
|
<mk-calendar @chosen="warp" :start="new Date(user.createdAt)"/>
|
||||||
@ -131,6 +132,10 @@ root(isDark)
|
|||||||
font-size 0.8em
|
font-size 0.8em
|
||||||
color #aaa
|
color #aaa
|
||||||
|
|
||||||
|
> .instance
|
||||||
|
box-shadow var(--shadow)
|
||||||
|
border-radius var(--round)
|
||||||
|
|
||||||
> .nav
|
> .nav
|
||||||
padding 16px
|
padding 16px
|
||||||
font-size 12px
|
font-size 12px
|
||||||
|
@ -187,6 +187,7 @@ export default Vue.extend({
|
|||||||
|
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
|
excludeNsfw: true,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then((notes: any[]) => {
|
}).then((notes: any[]) => {
|
||||||
const files = concat(notes.map((n: any): any[] => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
|
@ -265,7 +265,7 @@ export default class MiOS extends EventEmitter {
|
|||||||
// When success
|
// When success
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// When failed to authenticate user
|
// When failed to authenticate user
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200 && res.status < 500) {
|
||||||
return this.signout();
|
return this.signout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ export default Vue.extend({
|
|||||||
|
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
|
excludeNsfw: true,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then((notes: any[]) => {
|
}).then((notes: any[]) => {
|
||||||
const files = concat(notes.map((n: any): any[] => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
|
@ -20,6 +20,7 @@ Note.createIndex('userId');
|
|||||||
Note.createIndex('mentions');
|
Note.createIndex('mentions');
|
||||||
Note.createIndex('visibleUserIds');
|
Note.createIndex('visibleUserIds');
|
||||||
Note.createIndex('tagsLower');
|
Note.createIndex('tagsLower');
|
||||||
|
Note.createIndex('_files._id');
|
||||||
Note.createIndex('_files.contentType');
|
Note.createIndex('_files.contentType');
|
||||||
Note.createIndex({
|
Note.createIndex({
|
||||||
createdAt: -1
|
createdAt: -1
|
||||||
|
@ -55,6 +55,8 @@ export default class Resolver {
|
|||||||
Accept: 'application/activity+json, application/ld+json'
|
Accept: 'application/activity+json, application/ld+json'
|
||||||
},
|
},
|
||||||
json: true
|
json: true
|
||||||
|
}).catch(e => {
|
||||||
|
throw new Error(`request error: ${e.message}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (object === null || (
|
if (object === null || (
|
||||||
|
@ -4,6 +4,7 @@ import DriveFile, { validateFileName, pack } from '../../../../../models/drive-f
|
|||||||
import { publishDriveStream } from '../../../../../stream';
|
import { publishDriveStream } from '../../../../../stream';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
import { ILocalUser } from '../../../../../models/user';
|
||||||
import getParams from '../../../get-params';
|
import getParams from '../../../get-params';
|
||||||
|
import Note from '../../../../../models/note';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -93,6 +94,18 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ドライブのファイルが非正規化されているドキュメントも更新
|
||||||
|
Note.find({
|
||||||
|
'_files._id': file._id
|
||||||
|
}).then(notes => {
|
||||||
|
notes.forEach(note => {
|
||||||
|
note._files[note._files.findIndex(f => f._id.equals(file._id))] = file;
|
||||||
|
Note.findOneAndUpdate({ _id: note._id }, {
|
||||||
|
_files: note._files
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const fileObj = await pack(file);
|
const fileObj = await pack(file);
|
||||||
|
|
||||||
|
@ -1,21 +1,35 @@
|
|||||||
import * as mongo from 'mongodb';
|
|
||||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||||
import User, { ILocalUser } from '../../../../models/user';
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import { pack } from '../../../../models/user';
|
import { pack } from '../../../../models/user';
|
||||||
import { deliverPinnedChange } from '../../../../services/i/pin';
|
import { deliverPinnedChange } from '../../../../services/i/pin';
|
||||||
|
import getParams from '../../get-params';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '指定した投稿をピン留めします。'
|
||||||
|
},
|
||||||
|
|
||||||
|
requireCredential: true,
|
||||||
|
|
||||||
|
kind: 'account-write',
|
||||||
|
|
||||||
|
params: {
|
||||||
|
noteId: $.type(ID).note({
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '対象の投稿のID'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Pin note
|
|
||||||
*/
|
|
||||||
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Get 'noteId' parameter
|
const [ps, psErr] = getParams(meta, params);
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
if (psErr) return rej(psErr);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
|
||||||
|
|
||||||
// Fetch pinee
|
// Fetch pinee
|
||||||
const note = await Note.findOne({
|
const note = await Note.findOne({
|
||||||
_id: noteId,
|
_id: ps.noteId,
|
||||||
userId: user._id
|
userId: user._id
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -23,21 +37,17 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res,
|
|||||||
return rej('note not found');
|
return rej('note not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
let addedId: mongo.ObjectID;
|
|
||||||
let removedId: mongo.ObjectID;
|
|
||||||
|
|
||||||
const pinnedNoteIds = user.pinnedNoteIds || [];
|
const pinnedNoteIds = user.pinnedNoteIds || [];
|
||||||
|
|
||||||
|
if (pinnedNoteIds.length > 5) {
|
||||||
|
return rej('cannot pin more notes');
|
||||||
|
}
|
||||||
|
|
||||||
if (pinnedNoteIds.some(id => id.equals(note._id))) {
|
if (pinnedNoteIds.some(id => id.equals(note._id))) {
|
||||||
return rej('already exists');
|
return rej('already exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
pinnedNoteIds.unshift(note._id);
|
pinnedNoteIds.unshift(note._id);
|
||||||
addedId = note._id;
|
|
||||||
|
|
||||||
if (pinnedNoteIds.length > 5) {
|
|
||||||
removedId = pinnedNoteIds.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
await User.update(user._id, {
|
await User.update(user._id, {
|
||||||
$set: {
|
$set: {
|
||||||
@ -45,14 +55,13 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
|
||||||
const iObj = await pack(user, user, {
|
const iObj = await pack(user, user, {
|
||||||
detail: true
|
detail: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send Add/Remove to followers
|
|
||||||
deliverPinnedChange(user._id, removedId, addedId);
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
res(iObj);
|
res(iObj);
|
||||||
|
|
||||||
|
// Send Add to followers
|
||||||
|
deliverPinnedChange(user._id, note._id, true);
|
||||||
});
|
});
|
||||||
|
57
src/server/api/endpoints/i/unpin.ts
Normal file
57
src/server/api/endpoints/i/unpin.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||||
|
import User, { ILocalUser } from '../../../../models/user';
|
||||||
|
import Note from '../../../../models/note';
|
||||||
|
import { pack } from '../../../../models/user';
|
||||||
|
import { deliverPinnedChange } from '../../../../services/i/pin';
|
||||||
|
import getParams from '../../get-params';
|
||||||
|
|
||||||
|
export const meta = {
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '指定した投稿のピン留めを解除します。'
|
||||||
|
},
|
||||||
|
|
||||||
|
requireCredential: true,
|
||||||
|
|
||||||
|
kind: 'account-write',
|
||||||
|
|
||||||
|
params: {
|
||||||
|
noteId: $.type(ID).note({
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '対象の投稿のID'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
|
const [ps, psErr] = getParams(meta, params);
|
||||||
|
if (psErr) return rej(psErr);
|
||||||
|
|
||||||
|
// Fetch unpinee
|
||||||
|
const note = await Note.findOne({
|
||||||
|
_id: ps.noteId,
|
||||||
|
userId: user._id
|
||||||
|
});
|
||||||
|
|
||||||
|
if (note === null) {
|
||||||
|
return rej('note not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
const pinnedNoteIds = (user.pinnedNoteIds || []).filter(id => !id.equals(note._id));
|
||||||
|
|
||||||
|
await User.update(user._id, {
|
||||||
|
$set: {
|
||||||
|
pinnedNoteIds: pinnedNoteIds
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const iObj = await pack(user, user, {
|
||||||
|
detail: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send response
|
||||||
|
res(iObj);
|
||||||
|
|
||||||
|
// Send Remove to followers
|
||||||
|
deliverPinnedChange(user._id, note._id, false);
|
||||||
|
});
|
@ -2,6 +2,7 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
|||||||
import Favorite from '../../../../../models/favorite';
|
import Favorite from '../../../../../models/favorite';
|
||||||
import Note from '../../../../../models/note';
|
import Note from '../../../../../models/note';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
import { ILocalUser } from '../../../../../models/user';
|
||||||
|
import getParams from '../../../get-params';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -11,17 +12,24 @@ export const meta = {
|
|||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
|
|
||||||
kind: 'favorite-write'
|
kind: 'favorite-write',
|
||||||
|
|
||||||
|
params: {
|
||||||
|
noteId: $.type(ID).note({
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '対象の投稿のID'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Get 'noteId' parameter
|
const [ps, psErr] = getParams(meta, params);
|
||||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
if (psErr) return rej(psErr);
|
||||||
if (noteIdErr) return rej('invalid noteId param');
|
|
||||||
|
|
||||||
// Get favoritee
|
// Get favoritee
|
||||||
const note = await Note.findOne({
|
const note = await Note.findOne({
|
||||||
_id: noteId
|
_id: ps.noteId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (note === null) {
|
if (note === null) {
|
||||||
|
@ -30,6 +30,13 @@ export const meta = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
excludeNsfw: $.bool.optional.note({
|
||||||
|
default: false,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
limit: $.num.optional.range(1, 100).note({
|
limit: $.num.optional.range(1, 100).note({
|
||||||
default: 10
|
default: 10
|
||||||
}),
|
}),
|
||||||
@ -97,6 +104,12 @@ export default async (params: any, user: ILocalUser) => {
|
|||||||
query['_files.contentType'] = {
|
query['_files.contentType'] = {
|
||||||
$in: ps.fileType
|
$in: ps.fileType
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ps.excludeNsfw) {
|
||||||
|
query['_files.metadata.isSensitive'] = {
|
||||||
|
$ne: true
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.sinceId) {
|
if (ps.sinceId) {
|
||||||
|
@ -7,7 +7,7 @@ import renderRemove from '../../remote/activitypub/renderer/remove';
|
|||||||
import packAp from '../../remote/activitypub/renderer';
|
import packAp from '../../remote/activitypub/renderer';
|
||||||
import { deliver } from '../../queue';
|
import { deliver } from '../../queue';
|
||||||
|
|
||||||
export async function deliverPinnedChange(userId: mongo.ObjectID, oldId?: mongo.ObjectID, newId?: mongo.ObjectID) {
|
export async function deliverPinnedChange(userId: mongo.ObjectID, noteId: mongo.ObjectID, isAddition: boolean) {
|
||||||
const user = await User.findOne({
|
const user = await User.findOne({
|
||||||
_id: userId
|
_id: userId
|
||||||
});
|
});
|
||||||
@ -20,23 +20,13 @@ export async function deliverPinnedChange(userId: mongo.ObjectID, oldId?: mongo.
|
|||||||
|
|
||||||
const target = `${config.url}/users/${user._id}/collections/featured`;
|
const target = `${config.url}/users/${user._id}/collections/featured`;
|
||||||
|
|
||||||
if (oldId) {
|
const item = `${config.url}/notes/${noteId}`;
|
||||||
const oldItem = `${config.url}/notes/${oldId}`;
|
const content = packAp(isAddition ? renderAdd(user, target, item) : renderRemove(user, target, item));
|
||||||
const content = packAp(renderRemove(user, target, oldItem));
|
|
||||||
queue.forEach(inbox => {
|
queue.forEach(inbox => {
|
||||||
deliver(user, content, inbox);
|
deliver(user, content, inbox);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newId) {
|
|
||||||
const newItem = `${config.url}/notes/${newId}`;
|
|
||||||
const content = packAp(renderAdd(user, target, newItem));
|
|
||||||
queue.forEach(inbox => {
|
|
||||||
deliver(user, content, inbox);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ローカルユーザーのリモートフォロワーのinboxリストを作成する
|
* ローカルユーザーのリモートフォロワーのinboxリストを作成する
|
||||||
* @param user ローカルユーザー
|
* @param user ローカルユーザー
|
||||||
|
@ -118,6 +118,11 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
|||||||
return rej();
|
return rej();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renote対象が「ホームまたは全体」以外の公開範囲ならreject
|
||||||
|
if (data.renote && data.renote.visibility != 'public' && data.renote.visibility != 'home') {
|
||||||
|
return rej();
|
||||||
|
}
|
||||||
|
|
||||||
// リプライ対象が自分以外の非公開の投稿なら禁止
|
// リプライ対象が自分以外の非公開の投稿なら禁止
|
||||||
if (data.reply && data.reply.visibility == 'private' && !data.reply.userId.equals(user._id)) {
|
if (data.reply && data.reply.visibility == 'private' && !data.reply.userId.equals(user._id)) {
|
||||||
return rej();
|
return rej();
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
const { VueLoaderPlugin } = require('vue-loader');
|
const { VueLoaderPlugin } = require('vue-loader');
|
||||||
const minifyHtml = require('html-minifier').minify;
|
const minifyHtml = require('html-minifier').minify;
|
||||||
const WebpackOnBuildPlugin = require('on-build-webpack');
|
const WebpackOnBuildPlugin = require('on-build-webpack');
|
||||||
@ -19,7 +18,7 @@ const constants = require('./src/const.json');
|
|||||||
|
|
||||||
const locales = require('./locales');
|
const locales = require('./locales');
|
||||||
const meta = require('./package.json');
|
const meta = require('./package.json');
|
||||||
const version = `${meta.clientVersion}-${rndstr({ length: 8, chars: '0-9a-z' })}`;
|
const version = meta.clientVersion;
|
||||||
const codename = meta.codename;
|
const codename = meta.codename;
|
||||||
|
|
||||||
declare var global: {
|
declare var global: {
|
||||||
|
Reference in New Issue
Block a user