Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
dc80d5d376 | |||
d3544f9637 | |||
864b6ad1bd | |||
c58027e521 | |||
10fb399588 | |||
10f466c895 | |||
32068b4bcc | |||
8bc5febe66 | |||
20335e23f9 | |||
fe707f88a4 | |||
9b23ebd4a3 |
@ -116,7 +116,7 @@ Please see [Contribution guide](./CONTRIBUTING.md).
|
||||
<td><a href="https://www.patreon.com/user?u=12531784">Takashi Shibuya</a></td>
|
||||
</tr></table>
|
||||
|
||||
**Last updated:** Tue, 27 Nov 2018 06:24:05 UTC
|
||||
**Last updated:** Sat, 01 Dec 2018 22:05:05 UTC
|
||||
<!-- PATREON_END -->
|
||||
|
||||
:four_leaf_clover: Copyright
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "misskey",
|
||||
"author": "syuilo <i@syuilo.com>",
|
||||
"version": "10.59.3",
|
||||
"clientVersion": "2.0.12313",
|
||||
"version": "10.59.4",
|
||||
"clientVersion": "2.0.12323",
|
||||
"codename": "nighthike",
|
||||
"main": "./built/index.js",
|
||||
"private": true,
|
||||
|
@ -187,7 +187,8 @@ export default Vue.extend({
|
||||
} else {
|
||||
this.$root.api('users/search', {
|
||||
query: this.q,
|
||||
limit: 10
|
||||
limit: 10,
|
||||
detail: false
|
||||
}).then(users => {
|
||||
this.users = users;
|
||||
this.fetching = false;
|
||||
|
@ -116,7 +116,8 @@ export default Vue.extend({
|
||||
this.$root.api('users/search', {
|
||||
query: this.q,
|
||||
localOnly: true,
|
||||
limit: 10
|
||||
limit: 10,
|
||||
detail: false
|
||||
}).then(users => {
|
||||
this.result = users.filter(user => user.id != this.$store.state.i.id);
|
||||
});
|
||||
|
@ -39,7 +39,7 @@
|
||||
</header>
|
||||
<div class="body">
|
||||
<p v-if="appearNote.cw != null" class="cw">
|
||||
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="appearNote.cw == null || showContent">
|
||||
|
@ -5,7 +5,7 @@
|
||||
<mk-note-header class="header" :note="note" :mini="true"/>
|
||||
<div class="body">
|
||||
<p v-if="note.cw != null" class="cw">
|
||||
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="note.cw == null || showContent">
|
||||
|
@ -5,7 +5,7 @@
|
||||
<mk-note-header class="header" :note="note"/>
|
||||
<div class="body">
|
||||
<p v-if="note.cw != null" class="cw">
|
||||
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="note.cw == null || showContent">
|
||||
|
@ -20,7 +20,7 @@
|
||||
<mk-note-header class="header" :note="appearNote" :mini="mini"/>
|
||||
<div class="body" v-if="appearNote.deletedAt == null">
|
||||
<p v-if="appearNote.cw != null" class="cw">
|
||||
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="appearNote.cw == null || showContent">
|
||||
|
@ -265,6 +265,7 @@ export default Vue.extend({
|
||||
display inline-block
|
||||
overflow hidden
|
||||
max-height 48px
|
||||
word-break break-all
|
||||
|
||||
.note-ref
|
||||
color var(--noteText)
|
||||
|
@ -144,6 +144,8 @@ import {
|
||||
faHdd as farHdd,
|
||||
faMoon as farMoon,
|
||||
faPlayCircle as farPlayCircle,
|
||||
faLightbulb as farLightbulb,
|
||||
faStickyNote as farStickyNote,
|
||||
} from '@fortawesome/free-regular-svg-icons';
|
||||
|
||||
import {
|
||||
@ -249,7 +251,7 @@ library.add(
|
||||
faSync,
|
||||
faArrowLeft,
|
||||
faMapMarker,
|
||||
faRobot,
|
||||
faRobot,
|
||||
|
||||
farBell,
|
||||
farEnvelope,
|
||||
@ -270,6 +272,8 @@ library.add(
|
||||
farHdd,
|
||||
farMoon,
|
||||
farPlayCircle,
|
||||
farLightbulb,
|
||||
farStickyNote,
|
||||
|
||||
fabTwitter,
|
||||
fabGithub,
|
||||
|
@ -26,7 +26,7 @@
|
||||
</header>
|
||||
<div class="body">
|
||||
<p v-if="appearNote.cw != null" class="cw">
|
||||
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="appearNote.cw == null || showContent">
|
||||
|
@ -5,7 +5,7 @@
|
||||
<mk-note-header class="header" :note="note" :mini="true"/>
|
||||
<div class="body">
|
||||
<p v-if="note.cw != null" class="cw">
|
||||
<span class="text" v-if="note.cw != ''">{{ note.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$store.state.i" :custom-emojis="note.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="note.cw == null || showContent">
|
||||
|
@ -16,7 +16,7 @@
|
||||
<mk-note-header class="header" :note="appearNote" :mini="true"/>
|
||||
<div class="body" v-if="appearNote.deletedAt == null">
|
||||
<p v-if="appearNote.cw != null" class="cw">
|
||||
<span class="text" v-if="appearNote.cw != ''">{{ appearNote.cw }}</span>
|
||||
<misskey-flavored-markdown v-if="appearNote.cw != ''" class="text" :text="appearNote.cw" :author="appearNote.user" :i="$store.state.i" :custom-emojis="appearNote.emojis" />
|
||||
<mk-cw-button v-model="showContent"/>
|
||||
</p>
|
||||
<div class="content" v-show="appearNote.cw == null || showContent">
|
||||
|
@ -26,45 +26,6 @@ export default (source: string): Node[] => {
|
||||
nodes = concatText(nodes);
|
||||
concatTextRecursive(nodes);
|
||||
|
||||
function getBeforeTextNode(node: Node): Node {
|
||||
if (node == null) return null;
|
||||
if (node.name == 'text') return node;
|
||||
if (node.children) return getBeforeTextNode(node.children[node.children.length - 1]);
|
||||
return null;
|
||||
}
|
||||
|
||||
function getAfterTextNode(node: Node): Node {
|
||||
if (node == null) return null;
|
||||
if (node.name == 'text') return node;
|
||||
if (node.children) return getBeforeTextNode(node.children[0]);
|
||||
return null;
|
||||
}
|
||||
|
||||
function isBlockNode(node: Node): boolean {
|
||||
return ['blockCode', 'center', 'quote', 'title'].includes(node.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロック要素の前後にある改行を削除します
|
||||
* (ブロック要素自体が改行の役割を果たすため、余計に改行されてしまう)
|
||||
* @param nodes
|
||||
*/
|
||||
const removeNeedlessLineBreaks = (nodes: Node[]) => {
|
||||
nodes.forEach((node, i) => {
|
||||
if (node.children) removeNeedlessLineBreaks(node.children);
|
||||
if (isBlockNode(node)) {
|
||||
const before = getBeforeTextNode(nodes[i - 1]);
|
||||
const after = getAfterTextNode(nodes[i + 1]);
|
||||
if (before && before.props.text.endsWith('\n')) {
|
||||
before.props.text = before.props.text.substring(0, before.props.text.length - 1);
|
||||
}
|
||||
if (after && after.props.text.startsWith('\n')) {
|
||||
after.props.text = after.props.text.substring(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const removeEmptyTextNodes = (nodes: Node[]) => {
|
||||
nodes.forEach(n => {
|
||||
if (n.children) {
|
||||
@ -74,8 +35,6 @@ export default (source: string): Node[] => {
|
||||
return nodes.filter(n => !(n.name == 'text' && n.props.text == ''));
|
||||
};
|
||||
|
||||
removeNeedlessLineBreaks(nodes);
|
||||
|
||||
nodes = removeEmptyTextNodes(nodes);
|
||||
|
||||
return nodes;
|
||||
|
@ -162,7 +162,7 @@ const mfm = P.createLanguage({
|
||||
let hashtag = match[1];
|
||||
hashtag = hashtag.substr(0, getTrailingPosition(hashtag));
|
||||
if (hashtag.match(/^[0-9]+$/)) return P.makeFailure(i, 'not a hashtag');
|
||||
if (!['\n', ' ', ' ', '(', '「', null, undefined].includes(input[i - 1])) return P.makeFailure(i, 'require space before "#"');
|
||||
if (input[i - 1] != null && input[i - 1].match(/[a-z0-9]/i)) return P.makeFailure(i, 'not a hashtag');
|
||||
return P.makeSuccess(i + ('#' + hashtag).length, makeNode('hashtag', { hashtag: hashtag }));
|
||||
}),
|
||||
//#endregion
|
||||
@ -254,7 +254,7 @@ const mfm = P.createLanguage({
|
||||
const qInner = quote.join('\n').replace(/^>/gm, '').replace(/^ /gm, '');
|
||||
if (qInner == '') return P.makeFailure(i, 'not a quote');
|
||||
const contents = r.root.tryParse(qInner);
|
||||
return P.makeSuccess(i + quote.join('\n').length, makeNodeWithChildren('quote', contents));
|
||||
return P.makeSuccess(i + quote.join('\n').length + 1, makeNodeWithChildren('quote', contents));
|
||||
})),
|
||||
//#endregion
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
const ms = require('ms');
|
||||
import $ from 'cafy';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
import User, { pack, ILocalUser } from '../../../../models/user';
|
||||
import { getFriendIds } from '../../common/get-friends';
|
||||
import Mute from '../../../../models/mute';
|
||||
import * as request from 'request';
|
||||
import * as request from 'request-promise-native';
|
||||
import config from '../../../../config';
|
||||
import define from '../../define';
|
||||
import fetchMeta from '../../../../misc/fetch-meta';
|
||||
import resolveUser from '../../../../remote/resolve-user';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@ -53,13 +54,10 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
json: true,
|
||||
followRedirect: true,
|
||||
followAllRedirects: true
|
||||
}, (error: any, response: any, body: any) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
res(body);
|
||||
} else {
|
||||
res([]);
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(body => convertUsers(body, me))
|
||||
.then(packed => res(packed))
|
||||
.catch(e => rej(e));
|
||||
} else {
|
||||
// ID list of the user itself and other users who the user follows
|
||||
const followingIds = await getFriendIds(me._id);
|
||||
@ -90,3 +88,30 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
res(await Promise.all(users.map(user => pack(user, me, { detail: true }))));
|
||||
}
|
||||
}));
|
||||
|
||||
type IRecommendUser = {
|
||||
name: string;
|
||||
username: string;
|
||||
host: string;
|
||||
description: string;
|
||||
avatarUrl: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve/Pack dummy users
|
||||
*/
|
||||
async function convertUsers(src: IRecommendUser[], me: ILocalUser) {
|
||||
const packed = await Promise.all(src.map(async x => {
|
||||
const user = await resolveUser(x.username, x.host)
|
||||
.catch(() => {
|
||||
console.warn(`Can't resolve ${x.username}@${x.host}`);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (user == null) return x;
|
||||
|
||||
return await pack(user, me, { detail: true });
|
||||
}));
|
||||
|
||||
return packed;
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ export const meta = {
|
||||
'ja-JP': 'ローカルユーザーのみ検索対象にするか否か'
|
||||
}
|
||||
},
|
||||
|
||||
detail: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': '詳細なユーザー情報を含めるか否か'
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -72,6 +80,5 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize
|
||||
res(await Promise.all(users.map(user => pack(user, me, { detail: true }))));
|
||||
res(await Promise.all(users.map(user => pack(user, me, { detail: ps.detail }))));
|
||||
}));
|
||||
|
@ -155,12 +155,14 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
|
||||
|
||||
// Parse MFM
|
||||
const tokens = data.text ? parse(data.text) : [];
|
||||
const cwTokens = data.cw ? parse(data.cw) : [];
|
||||
const combinedTokens = tokens.concat(cwTokens);
|
||||
|
||||
const tags = extractHashtags(tokens);
|
||||
const tags = extractHashtags(combinedTokens);
|
||||
|
||||
const emojis = extractEmojis(tokens);
|
||||
const emojis = extractEmojis(combinedTokens);
|
||||
|
||||
const mentionedUsers = data.apMentions || await extractMentionedUsers(user, tokens);
|
||||
const mentionedUsers = data.apMentions || await extractMentionedUsers(user, combinedTokens);
|
||||
|
||||
if (data.reply && !user._id.equals(data.reply.userId) && !mentionedUsers.some(u => u._id.equals(data.reply.userId))) {
|
||||
mentionedUsers.push(await User.findOne({ _id: data.reply.userId }));
|
||||
|
33
test/mfm.ts
33
test/mfm.ts
@ -187,9 +187,9 @@ describe('Text', () => {
|
||||
});
|
||||
|
||||
it('with text (zenkaku)', () => {
|
||||
const tokens = analyze('こんにちは #世界');
|
||||
const tokens = analyze('こんにちは#世界');
|
||||
assert.deepEqual([
|
||||
text('こんにちは '),
|
||||
text('こんにちは'),
|
||||
node('hashtag', { hashtag: '世界' })
|
||||
], tokens);
|
||||
});
|
||||
@ -299,6 +299,7 @@ describe('Text', () => {
|
||||
nodeWithChildren('quote', [
|
||||
text('foo')
|
||||
]),
|
||||
text('\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('bar')
|
||||
]),
|
||||
@ -358,7 +359,7 @@ describe('Text', () => {
|
||||
it('with before and after texts', () => {
|
||||
const tokens = analyze('before\n> foo\nafter');
|
||||
assert.deepEqual([
|
||||
text('before'),
|
||||
text('before\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('foo')
|
||||
]),
|
||||
@ -366,6 +367,24 @@ describe('Text', () => {
|
||||
], tokens);
|
||||
});
|
||||
|
||||
it('multiple quotes', () => {
|
||||
const tokens = analyze('> foo\nbar\n\n> foo\nbar\n\n> foo\nbar');
|
||||
assert.deepEqual([
|
||||
nodeWithChildren('quote', [
|
||||
text('foo')
|
||||
]),
|
||||
text('bar\n\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('foo')
|
||||
]),
|
||||
text('bar\n\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('foo')
|
||||
]),
|
||||
text('bar'),
|
||||
], tokens);
|
||||
});
|
||||
|
||||
it('require line break before ">"', () => {
|
||||
const tokens = analyze('foo>bar');
|
||||
assert.deepEqual([
|
||||
@ -388,11 +407,11 @@ describe('Text', () => {
|
||||
it('trim line breaks', () => {
|
||||
const tokens = analyze('foo\n\n>a\n>>b\n>>\n>>>\n>>>c\n>>>\n>d\n\n');
|
||||
assert.deepEqual([
|
||||
text('foo\n'),
|
||||
text('foo\n\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('a'),
|
||||
text('a\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('b\n'),
|
||||
text('b\n\n'),
|
||||
nodeWithChildren('quote', [
|
||||
text('\nc\n')
|
||||
])
|
||||
@ -664,7 +683,7 @@ describe('Text', () => {
|
||||
it('with before and after texts', () => {
|
||||
const tokens = analyze('before\n【foo】\nafter');
|
||||
assert.deepEqual([
|
||||
text('before'),
|
||||
text('before\n'),
|
||||
nodeWithChildren('title', [
|
||||
text('foo')
|
||||
]),
|
||||
|
Reference in New Issue
Block a user