Refactor API (#4770)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update description.ts

* wip
This commit is contained in:
syuilo
2019-04-23 22:35:26 +09:00
committed by GitHub
parent f31f986d66
commit 0463c6bb0f
105 changed files with 1622 additions and 808 deletions

View File

@@ -3,6 +3,7 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
import { Notes } from '../../../../models';
import { PackedNote } from '../../../../models/repositories/note';
export default class extends Channel {
public readonly chName = 'globalTimeline';
@@ -21,7 +22,7 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
private async onNote(note: PackedNote) {
if (note.visibility !== 'public') return;
// リプライなら再pack

View File

@@ -2,6 +2,7 @@ import autobind from 'autobind-decorator';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import { Notes } from '../../../../models';
import { PackedNote } from '../../../../models/repositories/note';
export default class extends Channel {
public readonly chName = 'hashtag';
@@ -20,8 +21,8 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
const noteTags = note.tags.map((t: string) => t.toLowerCase());
private async onNote(note: PackedNote) {
const noteTags = note.tags ? note.tags.map((t: string) => t.toLowerCase()) : [];
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(tag.toLowerCase())));
if (!matched) return;

View File

@@ -2,6 +2,7 @@ import autobind from 'autobind-decorator';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import { Notes } from '../../../../models';
import { PackedNote } from '../../../../models/repositories/note';
export default class extends Channel {
public readonly chName = 'homeTimeline';
@@ -15,7 +16,7 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
private async onNote(note: PackedNote) {
// その投稿のユーザーをフォローしていなかったら弾く
if (this.user!.id !== note.userId && !this.following.includes(note.userId)) return;

View File

@@ -3,6 +3,8 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
import { Notes } from '../../../../models';
import { PackedNote } from '../../../../models/repositories/note';
import { PackedUser } from '../../../../models/repositories/user';
export default class extends Channel {
public readonly chName = 'hybridTimeline';
@@ -19,12 +21,12 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
private async onNote(note: PackedNote) {
// 自分自身の投稿 または その投稿のユーザーをフォローしている または 全体公開のローカルの投稿 の場合だけ
if (!(
this.user!.id === note.userId ||
this.following.includes(note.userId) ||
(note.user.host == null && note.visibility === 'public')
((note.user as PackedUser).host == null && note.visibility === 'public')
)) return;
if (['followers', 'specified'].includes(note.visibility)) {

View File

@@ -3,6 +3,8 @@ import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import Channel from '../channel';
import fetchMeta from '../../../../misc/fetch-meta';
import { Notes } from '../../../../models';
import { PackedNote } from '../../../../models/repositories/note';
import { PackedUser } from '../../../../models/repositories/user';
export default class extends Channel {
public readonly chName = 'localTimeline';
@@ -21,8 +23,8 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
if (note.user.host !== null) return;
private async onNote(note: PackedNote) {
if ((note.user as PackedUser).host !== null) return;
if (note.visibility === 'home') return;
if (['followers', 'specified'].includes(note.visibility)) {

View File

@@ -3,6 +3,7 @@ import Channel from '../channel';
import { Notes, UserListJoinings } from '../../../../models';
import shouldMuteThisNote from '../../../../misc/should-mute-this-note';
import { User } from '../../../../models/entities/user';
import { PackedNote } from '../../../../models/repositories/note';
export default class extends Channel {
public readonly chName = 'userList';
@@ -38,7 +39,7 @@ export default class extends Channel {
}
@autobind
private async onNote(note: any) {
private async onNote(note: PackedNote) {
if (!this.listUsers.includes(note.userId)) return;
if (['followers', 'specified'].includes(note.visibility)) {