1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-08 17:25:37 +02:00

Compare commits

..

31 Commits

Author SHA1 Message Date
syuilo
f499630c2b 2.36.1 2018-06-11 01:28:45 +09:00
syuilo
43319a8588 Merge pull request #1694 from syuilo/l10n_master
New Crowdin translations
2018-06-11 01:21:52 +09:00
syuilo
d62b943c5d New translations ja.yml (English) 2018-06-11 01:21:03 +09:00
syuilo
8baddf2ea3 Fix #1695 2018-06-11 01:14:29 +09:00
syuilo
600482660b タグは最大100文字までにした 2018-06-11 01:12:37 +09:00
syuilo
72ab5c143e Revert "✌️"
This reverts commit 96ab0e7b4c.
2018-06-11 01:07:34 +09:00
syuilo
96ab0e7b4c ✌️ 2018-06-11 00:27:16 +09:00
syuilo
b60903e2b4 🍕 2018-06-11 00:24:03 +09:00
syuilo
b4f4d3f267 New translations ja.yml (Portuguese) 2018-06-10 12:51:00 +09:00
syuilo
6e017c86e8 New translations ja.yml (Korean) 2018-06-10 12:50:58 +09:00
syuilo
afcfc2dca5 New translations ja.yml (Polish) 2018-06-10 12:50:57 +09:00
syuilo
59e22a12a9 New translations ja.yml (Chinese Simplified) 2018-06-10 12:50:55 +09:00
syuilo
b740ac3e01 New translations ja.yml (Italian) 2018-06-10 12:50:53 +09:00
syuilo
9719f0df03 New translations ja.yml (Russian) 2018-06-10 12:50:51 +09:00
syuilo
d4be599538 New translations ja.yml (English) 2018-06-10 12:50:49 +09:00
syuilo
f88195c90a New translations ja.yml (Spanish) 2018-06-10 12:50:47 +09:00
syuilo
3b33f7e752 New translations ja.yml (German) 2018-06-10 12:50:46 +09:00
syuilo
67a37294f7 New translations ja.yml (French) 2018-06-10 12:50:43 +09:00
syuilo
fd88955696 ✌️ 2018-06-10 12:36:48 +09:00
syuilo
9d248dbb5a 🎨 2018-06-10 12:29:19 +09:00
syuilo
20ec4104c6 2.36.0 2018-06-10 12:22:48 +09:00
syuilo
6c232d116d Merge pull request #1692 from syuilo/l10n_master
New Crowdin translations
2018-06-10 12:22:28 +09:00
syuilo
2ef78bcd40 🍕 2018-06-10 12:21:44 +09:00
syuilo
94ce658ab9 ハッシュタグ検索を実装 2018-06-10 12:19:19 +09:00
syuilo
d8cf4cd341 New translations ja.yml (Polish) 2018-06-10 10:30:48 +09:00
syuilo
0360337df9 2.35.3 2018-06-10 08:42:29 +09:00
syuilo
119d38ea08 Fix bug 2018-06-10 08:41:57 +09:00
syuilo
bee77afb7f Fix bug 2018-06-10 08:34:46 +09:00
syuilo
16d4b16872 Revert "✌️"
This reverts commit 951b2346ab.
2018-06-10 08:21:48 +09:00
syuilo
951b2346ab ✌️ 2018-06-10 08:15:05 +09:00
syuilo
b29ff0e94b ✌️ 2018-06-10 08:03:02 +09:00
32 changed files with 593 additions and 45 deletions

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "Only media posts"
is-media-view: "Media view"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "Reposted by {}"
private: "this post is private"
deleted: "this post has been deleted"
desktop/views/pages/welcome.vue:
about: "about"
gotit: "Got it!"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "à propos"
gotit: "J'ai compris !"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -672,6 +672,11 @@ desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -54,7 +54,7 @@ common:
timemachine: "Kalendarz (wehikuł czasu)"
activity: "Aktywność"
rss: "Czytnik RSS"
memo: "付箋"
memo: "Notatka"
trends: "Na czasie"
photo-stream: "Photostream"
posts-monitor: "Wykres wpisów"
@@ -63,7 +63,7 @@ common:
broadcast: "Transmisja"
notifications: "Powiadomienia"
users: "Polecani użytkownicy"
polls: "アンケート"
polls: "Ankiety"
post-form: "Formularz tworzenia"
messaging: "Wiadomości"
server: "Informacje o serwerze"
@@ -151,11 +151,11 @@ common/views/components/poll.vue:
show-result: "Pokaż wyniki"
voted: "Zagłosowano"
common/views/components/poll-editor.vue:
no-only-one-choice: "アンケートには、選択肢が最低2つ必要です"
no-only-one-choice: "Musisz wprowadzić przynajmniej dwie opcje."
choice-n: "Opcja {}"
remove: "Usuń tą opcję"
add: "+ Dodaj opcję"
destroy: "アンケートを破棄"
destroy: "Usuń tę ankietę"
common/views/components/reaction-picker.vue:
choose-reaction: "Wybierz reakcję"
common/views/components/signin.vue:
@@ -228,7 +228,7 @@ common/views/widgets/server.vue:
title: "Informacje o serwerze"
toggle: "Przełącz widok"
common/views/widgets/memo.vue:
title: "付箋"
title: "Notatka"
memo: "Napisz tutaj!"
save: "Zapisz"
desktop/views/components/activity.chart.vue:
@@ -380,7 +380,7 @@ desktop/views/components/post-form.vue:
attach-media-from-drive: "Załącz zawartość multimedialną z dysku"
attach-cancel: "Usuń załącznik"
insert-a-kao: "v(‘ω’)v"
create-poll: "アンケートを作成"
create-poll: "Utwórz ankietę"
text-remain: "pozostałe znaki: {}"
desktop/views/components/post-form-window.vue:
note: "Nowy wpis"
@@ -523,7 +523,7 @@ desktop/views/components/sub-note-content.vue:
private: "ten wpis jest prywatny"
deleted: "ten wpis został usunięty"
media-count: "{}zawartości multimedialnej"
poll: "アンケート"
poll: "Ankieta"
desktop/views/components/taskmanager.vue:
title: "Menedżer zadań"
desktop/views/components/timeline.vue:
@@ -574,8 +574,12 @@ desktop/views/components/window.vue:
popout: "Pop-out"
close: "Zamknij"
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
is-media-only: "Tylko wpisy z zawartością multimedialną"
is-media-view: "Widok multimediów"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "O Misskey"
gotit: "Rozumiem!"
@@ -639,7 +643,7 @@ desktop/views/widgets/notifications.vue:
title: "Powiadomienia"
settings: "Ustawienia"
desktop/views/widgets/polls.vue:
title: "アンケート"
title: "Ankiety"
refresh: "Pokaż inne"
nothing: "Pusto"
desktop/views/widgets/post-form.vue:
@@ -738,7 +742,7 @@ mobile/views/components/sub-note-content.vue:
private: "ten wpis jest prywatny"
deleted: "ten wpis został usunięty"
media-count: "{}zawartości multimedialnej"
poll: "アンケート"
poll: "Ankieta"
mobile/views/components/timeline.vue:
empty: "Brak wpisów"
load-more: "Więcej"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -576,6 +576,10 @@ desktop/views/components/window.vue:
desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー"
desktop/views/pages/deck/deck.note.vue:
reposted-by: "{}がRenote"
private: "この投稿は非公開です"
deleted: "この投稿は削除されました"
desktop/views/pages/welcome.vue:
about: "詳しく..."
gotit: "わかった"

View File

@@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "2.35.2",
"clientVersion": "1.0.6360",
"version": "2.36.1",
"clientVersion": "1.0.6396",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@@ -58,18 +58,21 @@ export default Vue.extend({
},
created() {
if (this.mode == 'relative' || this.mode == 'detail') {
this.tick();
this.tickId = setInterval(this.tick, 10000);
this.tickId = window.requestAnimationFrame(this.tick);
}
},
destroyed() {
if (this.mode === 'relative' || this.mode === 'detail') {
clearInterval(this.tickId);
window.clearTimeout(this.tickId);
}
},
methods: {
tick() {
this.now = new Date();
this.tickId = setTimeout(() => {
window.requestAnimationFrame(this.tick);
}, 10000);
}
}
});

View File

@@ -203,6 +203,7 @@ root(isDark)
justify-content center
align-items center
margin-right 10px
width 16px
> *:last-child
flex 1 1 auto

View File

@@ -33,6 +33,7 @@ import MkHomeCustomize from './views/pages/home-customize.vue';
import MkMessagingRoom from './views/pages/messaging-room.vue';
import MkNote from './views/pages/note.vue';
import MkSearch from './views/pages/search.vue';
import MkTag from './views/pages/tag.vue';
import MkOthello from './views/pages/othello.vue';
/**
@@ -60,6 +61,7 @@ init(async (launch) => {
{ path: '/i/lists/:list', component: MkUserList },
{ path: '/selectdrive', component: MkSelectDrive },
{ path: '/search', component: MkSearch },
{ path: '/tags/:tag', component: MkTag },
{ path: '/othello', component: MkOthello },
{ path: '/othello/:game', component: MkOthello },
{ path: '/@:user', component: MkUser },

View File

@@ -48,7 +48,7 @@
<mk-poll v-if="p.poll" :note="p"/>
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
<router-link v-for="tag in p.tags" :key="tag" :to="`/tags/${tag}`">{{ tag }}</router-link>
</div>
<a class="location" v-if="p.geo" :href="`http://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="map" v-if="p.geo" ref="map"></div>

View File

@@ -1,6 +1,6 @@
<template>
<div class="mk-note-preview" :title="title">
<mk-avatar class="avatar" :user="note.user"/>
<mk-avatar class="avatar" :user="note.user" v-if="!mini"/>
<div class="main">
<mk-note-header class="header" :note="note" :mini="true"/>
<div class="body">
@@ -15,7 +15,17 @@ import Vue from 'vue';
import dateStringify from '../../../common/scripts/date-stringify';
export default Vue.extend({
props: ['note'],
props: {
note: {
type: Object,
required: true
},
mini: {
type: Boolean,
required: false,
default: false
}
},
computed: {
title(): string {
return dateStringify(this.note.createdAt);

View File

@@ -33,7 +33,7 @@
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
<router-link v-for="tag in p.tags" :key="tag" :to="`/tags/${tag}`">{{ tag }}</router-link>
</div>
<a class="location" v-if="p.geo" :href="`http://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% 位置情報</a>
<div class="map" v-if="p.geo" ref="map"></div>

View File

@@ -17,7 +17,11 @@ export default Vue.extend({
},
methods: {
onSubmit() {
location.href = `/search?q=${encodeURIComponent(this.q)}`;
if (this.q.startsWith('#')) {
this.$router.push(`/tags/${encodeURIComponent(this.q.substr(1))}`);
} else {
this.$router.push(`/search?q=${encodeURIComponent(this.q)}`);
}
}
}
});

View File

@@ -33,11 +33,11 @@
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
<router-link v-for="tag in p.tags" :key="tag" :to="`/tags/${tag}`">{{ tag }}</router-link>
</div>
<a class="location" v-if="p.geo" :href="`http://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>
<div class="renote" v-if="p.renote">
<mk-note-preview :note="p.renote"/>
<mk-note-preview :note="p.renote" :mini="true"/>
</div>
</div>
<span class="app" v-if="p.app">via <b>{{ p.app.name }}</b></span>

View File

@@ -0,0 +1,128 @@
<template>
<mk-ui>
<header :class="$style.header">
<h1>#{{ $route.params.tag }}</h1>
</header>
<div :class="$style.loading" v-if="fetching">
<mk-ellipsis-icon/>
</div>
<p :class="$style.empty" v-if="!fetching && empty">%fa:search%{{ q }}に関する投稿は見つかりませんでした</p>
<mk-notes ref="timeline" :class="$style.notes" :more="existMore ? more : null"/>
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import Progress from '../../../common/scripts/loading';
const limit = 20;
export default Vue.extend({
data() {
return {
fetching: true,
moreFetching: false,
existMore: false,
offset: 0,
empty: false
};
},
watch: {
$route: 'fetch'
},
mounted() {
document.addEventListener('keydown', this.onDocumentKeydown);
window.addEventListener('scroll', this.onScroll, { passive: true });
this.fetch();
},
beforeDestroy() {
document.removeEventListener('keydown', this.onDocumentKeydown);
window.removeEventListener('scroll', this.onScroll);
},
methods: {
onDocumentKeydown(e) {
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
if (e.which == 84) { // t
(this.$refs.timeline as any).focus();
}
}
},
fetch() {
this.fetching = true;
Progress.start();
(this.$refs.timeline as any).init(() => new Promise((res, rej) => {
(this as any).api('notes/search_by_tag', {
limit: limit + 1,
offset: this.offset,
tag: this.$route.params.tag
}).then(notes => {
if (notes.length == 0) this.empty = true;
if (notes.length == limit + 1) {
notes.pop();
this.existMore = true;
}
res(notes);
this.fetching = false;
Progress.done();
}, rej);
}));
},
more() {
this.offset += limit;
const promise = (this as any).api('notes/search_by_tag', {
limit: limit + 1,
offset: this.offset,
tag: this.$route.params.tag
});
promise.then(notes => {
if (notes.length == limit + 1) {
notes.pop();
} else {
this.existMore = false;
}
notes.forEach(n => (this.$refs.timeline as any).append(n));
this.moreFetching = false;
});
return promise;
}
}
});
</script>
<style lang="stylus" module>
.header
width 100%
max-width 600px
margin 0 auto
color #555
.notes
width 600px
margin 0 auto
border solid 1px rgba(#000, 0.075)
border-radius 6px
overflow hidden
.loading
padding 64px 0
.empty
display block
margin 0 auto
padding 32px
max-width 400px
text-align center
color #999
> [data-fa]
display block
margin-bottom 16px
font-size 3em
color #ccc
</style>

View File

@@ -41,7 +41,7 @@
<mk-note-html v-if="p.text" :text="p.text" :i="$store.state.i"/>
</div>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
<router-link v-for="tag in p.tags" :key="tag" :to="`/tags/${tag}`">{{ tag }}</router-link>
</div>
<div class="media" v-if="p.media.length > 0">
<mk-media-list :media-list="p.media" :raw="true"/>

View File

@@ -33,7 +33,7 @@
</div>
<mk-poll v-if="p.poll" :note="p" ref="pollViewer"/>
<div class="tags" v-if="p.tags && p.tags.length > 0">
<router-link v-for="tag in p.tags" :key="tag" :to="`/search?q=#${tag}`">{{ tag }}</router-link>
<router-link v-for="tag in p.tags" :key="tag" :to="`/tags/${tag}`">{{ tag }}</router-link>
</div>
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
<a class="location" v-if="p.geo" :href="`http://maps.google.com/maps?q=${p.geo.coordinates[1]},${p.geo.coordinates[0]}`" target="_blank">%fa:map-marker-alt% %i18n:@location%</a>

View File

@@ -12,10 +12,7 @@ const uri = u && p
*/
import mongo from 'monk';
const db = mongo(uri, {
poolSize: 16,
keepAlive: 1
});
const db = mongo(uri);
export default db;

View File

@@ -16,6 +16,7 @@ import Following from './following';
const Note = db.get<INote>('notes');
Note.createIndex('uri', { sparse: true, unique: true });
Note.createIndex('userId');
Note.createIndex('tags', { sparse: true });
Note.createIndex({
createdAt: -1
});

View File

@@ -48,6 +48,8 @@ type IUserBase = {
usernameLower: string;
avatarId: mongo.ObjectID;
bannerId: mongo.ObjectID;
avatarUrl?: string;
bannerUrl?: string;
wallpaperId: mongo.ObjectID;
data: any;
description: string;
@@ -405,13 +407,17 @@ export const pack = (
delete _user.publicKey;
}
_user.avatarUrl = _user.avatarId != null
? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
if (_user.avatarUrl == null) {
_user.avatarUrl = _user.avatarId != null
? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
}
_user.bannerUrl = _user.bannerId != null
? `${config.drive_url}/${_user.bannerId}`
: null;
if (_user.bannerUrl == null) {
_user.bannerUrl = _user.bannerId != null
? `${config.drive_url}/${_user.bannerId}`
: null;
}
_user.wallpaperUrl = _user.wallpaperId != null
? `${config.drive_url}/${_user.wallpaperId}`

View File

@@ -9,6 +9,7 @@ import webFinger from '../../webfinger';
import Resolver from '../resolver';
import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type';
import { IDriveFile } from '../../../models/drive-file';
const log = debug('misskey:activitypub');
@@ -117,19 +118,33 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
}
//#region アイコンとヘッダー画像をフェッチ
const [avatarId, bannerId] = (await Promise.all([
const [avatar, banner] = (await Promise.all<IDriveFile>([
person.icon,
person.image
].map(img =>
img == null
? Promise.resolve(null)
: resolveImage(user, img)
))).map(file => file != null ? file._id : null);
)));
User.update({ _id: user._id }, { $set: { avatarId, bannerId } });
const avatarId = avatar ? avatar._id : null;
const bannerId = banner ? banner._id : null;
const avatarUrl = avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null;
const bannerUrl = banner && banner.metadata.isMetaOnly ? banner.metadata.url : null;
await User.update({ _id: user._id }, {
$set: {
avatarId,
bannerId,
avatarUrl,
bannerUrl
}
});
user.avatarId = avatarId;
user.bannerId = bannerId;
user.avatarUrl = avatarUrl;
user.bannerUrl = bannerUrl;
//#endregion
return user;
@@ -190,21 +205,23 @@ export async function updatePerson(value: string | IObject, resolver?: Resolver)
const summaryDOM = JSDOM.fragment(person.summary);
// アイコンとヘッダー画像をフェッチ
const [avatarId, bannerId] = (await Promise.all([
const [avatar, banner] = (await Promise.all<IDriveFile>([
person.icon,
person.image
].map(img =>
img == null
? Promise.resolve(null)
: resolveImage(exist, img)
))).map(file => file != null ? file._id : null);
)));
// Update user
await User.update({ _id: exist._id }, {
$set: {
updatedAt: new Date(),
avatarId,
bannerId,
avatarId: avatar ? avatar._id : null,
bannerId: banner ? banner._id : null,
avatarUrl: avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null,
bannerUrl: banner && banner.metadata.isMetaOnly ? banner.metadata.url : null,
description: summaryDOM.textContent,
followersCount,
followingCount,

View File

@@ -2,6 +2,6 @@ import config from '../../../config';
export default tag => ({
type: 'Hashtag',
href: `${config.url}/search?q=#${encodeURIComponent(tag)}`,
href: `${config.url}/tags/${encodeURIComponent(tag)}`,
name: '#' + tag
});

View File

@@ -525,6 +525,9 @@ const endpoints: Endpoint[] = [
{
name: 'notes/search'
},
{
name: 'notes/search_by_tag'
},
{
name: 'notes/timeline',
withCredential: true,

View File

@@ -0,0 +1,329 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import User from '../../../../models/user';
import Mute from '../../../../models/mute';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
/**
* Search notes by tag
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'tag' parameter
const [tag, tagError] = $.str.get(params.tag);
if (tagError) return rej('invalid tag param');
// Get 'includeUserIds' parameter
const [includeUserIds = [], includeUserIdsErr] = $.arr($.type(ID)).optional().get(params.includeUserIds);
if (includeUserIdsErr) return rej('invalid includeUserIds param');
// Get 'excludeUserIds' parameter
const [excludeUserIds = [], excludeUserIdsErr] = $.arr($.type(ID)).optional().get(params.excludeUserIds);
if (excludeUserIdsErr) return rej('invalid excludeUserIds param');
// Get 'includeUserUsernames' parameter
const [includeUserUsernames = [], includeUserUsernamesErr] = $.arr($.str).optional().get(params.includeUserUsernames);
if (includeUserUsernamesErr) return rej('invalid includeUserUsernames param');
// Get 'excludeUserUsernames' parameter
const [excludeUserUsernames = [], excludeUserUsernamesErr] = $.arr($.str).optional().get(params.excludeUserUsernames);
if (excludeUserUsernamesErr) return rej('invalid excludeUserUsernames param');
// Get 'following' parameter
const [following = null, followingErr] = $.bool.optional().nullable().get(params.following);
if (followingErr) return rej('invalid following param');
// Get 'mute' parameter
const [mute = 'mute_all', muteErr] = $.str.optional().get(params.mute);
if (muteErr) return rej('invalid mute param');
// Get 'reply' parameter
const [reply = null, replyErr] = $.bool.optional().nullable().get(params.reply);
if (replyErr) return rej('invalid reply param');
// Get 'renote' parameter
const [renote = null, renoteErr] = $.bool.optional().nullable().get(params.renote);
if (renoteErr) return rej('invalid renote param');
// Get 'media' parameter
const [media = null, mediaErr] = $.bool.optional().nullable().get(params.media);
if (mediaErr) return rej('invalid media param');
// Get 'poll' parameter
const [poll = null, pollErr] = $.bool.optional().nullable().get(params.poll);
if (pollErr) return rej('invalid poll param');
// Get 'sinceDate' parameter
const [sinceDate, sinceDateErr] = $.num.optional().get(params.sinceDate);
if (sinceDateErr) throw 'invalid sinceDate param';
// Get 'untilDate' parameter
const [untilDate, untilDateErr] = $.num.optional().get(params.untilDate);
if (untilDateErr) throw 'invalid untilDate param';
// Get 'offset' parameter
const [offset = 0, offsetErr] = $.num.optional().min(0).get(params.offset);
if (offsetErr) return rej('invalid offset param');
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 30).get(params.limit);
if (limitErr) return rej('invalid limit param');
let includeUsers = includeUserIds;
if (includeUserUsernames != null) {
const ids = (await Promise.all(includeUserUsernames.map(async (username) => {
const _user = await User.findOne({
usernameLower: username.toLowerCase()
});
return _user ? _user._id : null;
}))).filter(id => id != null);
includeUsers = includeUsers.concat(ids);
}
let excludeUsers = excludeUserIds;
if (excludeUserUsernames != null) {
const ids = (await Promise.all(excludeUserUsernames.map(async (username) => {
const _user = await User.findOne({
usernameLower: username.toLowerCase()
});
return _user ? _user._id : null;
}))).filter(id => id != null);
excludeUsers = excludeUsers.concat(ids);
}
search(res, rej, me, tag, includeUsers, excludeUsers, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, limit);
});
async function search(
res, rej, me, tag, includeUserIds, excludeUserIds, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, max) {
let q: any = {
$and: [{
tags: tag
}]
};
const push = x => q.$and.push(x);
if (includeUserIds && includeUserIds.length != 0) {
push({
userId: {
$in: includeUserIds
}
});
} else if (excludeUserIds && excludeUserIds.length != 0) {
push({
userId: {
$nin: excludeUserIds
}
});
}
if (following != null && me != null) {
const ids = await getFriendIds(me._id, false);
push({
userId: following ? {
$in: ids
} : {
$nin: ids.concat(me._id)
}
});
}
if (me != null) {
const mutes = await Mute.find({
muterId: me._id,
deletedAt: { $exists: false }
});
const mutedUserIds = mutes.map(m => m.muteeId);
switch (mute) {
case 'mute_all':
push({
userId: {
$nin: mutedUserIds
},
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
}
});
break;
case 'mute_related':
push({
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
}
});
break;
case 'mute_direct':
push({
userId: {
$nin: mutedUserIds
}
});
break;
case 'direct_only':
push({
userId: {
$in: mutedUserIds
}
});
break;
case 'related_only':
push({
$or: [{
'_reply.userId': {
$in: mutedUserIds
}
}, {
'_renote.userId': {
$in: mutedUserIds
}
}]
});
break;
case 'all_only':
push({
$or: [{
userId: {
$in: mutedUserIds
}
}, {
'_reply.userId': {
$in: mutedUserIds
}
}, {
'_renote.userId': {
$in: mutedUserIds
}
}]
});
break;
}
}
if (reply != null) {
if (reply) {
push({
replyId: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
replyId: {
$exists: false
}
}, {
replyId: null
}]
});
}
}
if (renote != null) {
if (renote) {
push({
renoteId: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
renoteId: {
$exists: false
}
}, {
renoteId: null
}]
});
}
}
if (media != null) {
if (media) {
push({
mediaIds: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
mediaIds: {
$exists: false
}
}, {
mediaIds: null
}]
});
}
}
if (poll != null) {
if (poll) {
push({
poll: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
poll: {
$exists: false
}
}, {
poll: null
}]
});
}
}
if (sinceDate) {
push({
createdAt: {
$gt: new Date(sinceDate)
}
});
}
if (untilDate) {
push({
createdAt: {
$lt: new Date(untilDate)
}
});
}
if (q.$and.length == 0) {
q = {};
}
// Search notes
const notes = await Note
.find(q, {
sort: {
_id: -1
},
limit: max,
skip: offset
});
// Serialize
res(await Promise.all(notes.map(note => pack(note, me))));
}

View File

@@ -94,7 +94,7 @@ export default async (user: IUser, data: {
if (data.visibility == null) data.visibility = 'public';
if (data.viaMobile == null) data.viaMobile = false;
const tags = data.tags || [];
let tags = data.tags || [];
let tokens: any[] = null;
@@ -114,6 +114,8 @@ export default async (user: IUser, data: {
});
}
tags = tags.filter(tag => tag.length <= 100);
if (data.visibleUsers) {
data.visibleUsers = data.visibleUsers.filter(x => x != null);
}

View File

@@ -25,7 +25,7 @@ const handlers = {
hashtag({ document }, { hashtag }) {
const a = document.createElement('a');
a.href = config.url + '/search?q=#' + hashtag;
a.href = config.url + '/tags/' + hashtag;
a.textContent = '#' + hashtag;
a.setAttribute('rel', 'tag');
document.body.appendChild(a);