refs #125 Implement sub timeline methods for misskey
This commit is contained in:
parent
2b1f15ad82
commit
aae498b7e9
159
src/misskey.ts
159
src/misskey.ts
|
@ -1400,4 +1400,163 @@ export default class Misskey {
|
|||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/user-list-timeline', params)
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n)) }))
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// timelines/conversations
|
||||
// ======================================
|
||||
/**
|
||||
* POST /api/notes/mentions
|
||||
*/
|
||||
public async getConversationTimeline(
|
||||
limit?: number | null,
|
||||
max_id?: string | null,
|
||||
since_id?: string | null,
|
||||
_min_id?: string | null
|
||||
): Promise<Response<Array<Entity.Conversation>>> {
|
||||
let params = {
|
||||
visibility: 'specified'
|
||||
}
|
||||
if (limit) {
|
||||
params = Object.assign(params, {
|
||||
limit: limit
|
||||
})
|
||||
}
|
||||
if (max_id) {
|
||||
params = Object.assign(params, {
|
||||
untilId: max_id
|
||||
})
|
||||
}
|
||||
if (since_id) {
|
||||
params = Object.assign(params, {
|
||||
sinceId: since_id
|
||||
})
|
||||
}
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/mentions', params)
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.noteToConversation(n)) }))
|
||||
}
|
||||
|
||||
public async deleteConversation(_id: string): Promise<Response<{}>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
public async readConversation(_id: string): Promise<Response<Entity.Conversation>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
// ======================================
|
||||
// timelines/lists
|
||||
// ======================================
|
||||
/**
|
||||
* POST /api/users/lists/list
|
||||
*/
|
||||
public async getLists(): Promise<Response<Array<Entity.List>>> {
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.List>>('/api/users/lists/list')
|
||||
.then(res => ({ ...res, data: res.data.map(l => MisskeyAPI.Converter.list(l)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/show
|
||||
*/
|
||||
public async getList(id: string): Promise<Response<Entity.List>> {
|
||||
return this.client
|
||||
.post<MisskeyAPI.Entity.List>('/api/users/lists/show', {
|
||||
listId: id
|
||||
})
|
||||
.then(res => ({ ...res, data: MisskeyAPI.Converter.list(res.data) }))
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/create
|
||||
*/
|
||||
public async createList(title: string): Promise<Response<Entity.List>> {
|
||||
return this.client
|
||||
.post<MisskeyAPI.Entity.List>('/api/users/lists/create', {
|
||||
name: title
|
||||
})
|
||||
.then(res => ({ ...res, data: MisskeyAPI.Converter.list(res.data) }))
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/update
|
||||
*/
|
||||
public async updateList(id: string, title: string): Promise<Response<Entity.List>> {
|
||||
return this.client
|
||||
.post<MisskeyAPI.Entity.List>('/api/users/lists/update', {
|
||||
listId: id,
|
||||
name: title
|
||||
})
|
||||
.then(res => ({ ...res, data: MisskeyAPI.Converter.list(res.data) }))
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/delete
|
||||
*/
|
||||
public async deleteList(id: string): Promise<Response<{}>> {
|
||||
return this.client.post<{}>('/api/users/lists/delete', {
|
||||
listId: id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/show
|
||||
*/
|
||||
public async getAccountsInList(
|
||||
id: string,
|
||||
_limit?: number | null,
|
||||
_max_id?: string | null,
|
||||
_since_id?: string | null
|
||||
): Promise<Response<Array<Entity.Account>>> {
|
||||
const res = await this.client.post<MisskeyAPI.Entity.List>('/api/users/lists/show', {
|
||||
listId: id
|
||||
})
|
||||
const promise = res.data.userIds.map(userId => this.getAccount(userId))
|
||||
const accounts = await Promise.all(promise)
|
||||
return { ...res, data: accounts.map(r => r.data) }
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/push
|
||||
*/
|
||||
public async addAccountsToList(id: string, account_ids: Array<string>): Promise<Response<{}>> {
|
||||
return await this.client.post<{}>('/api/users/lists/push', {
|
||||
listId: id,
|
||||
userId: account_ids[0]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/users/lists/pull
|
||||
*/
|
||||
public async deleteAccountsFromList(id: string, account_ids: Array<string>): Promise<Response<{}>> {
|
||||
return await this.client.post<{}>('/api/users/lists/pull', {
|
||||
listId: id,
|
||||
userId: account_ids[0]
|
||||
})
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// timelines/markers
|
||||
// ======================================
|
||||
public async getMarker(_timeline: Array<'home' | 'notifications'>): Promise<Response<Entity.Marker | {}>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
public async saveMarker(
|
||||
_home?: { last_read_id: string } | null,
|
||||
_notifications?: { last_read_id: string } | null
|
||||
): Promise<Response<Entity.Marker>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace MisskeyAPI {
|
|||
export type Follower = MisskeyEntity.Follower
|
||||
export type Following = MisskeyEntity.Following
|
||||
export type FollowRequest = MisskeyEntity.FollowRequest
|
||||
export type List = MisskeyEntity.List
|
||||
export type Mute = MisskeyEntity.Mute
|
||||
export type Note = MisskeyEntity.Note
|
||||
export type Poll = MisskeyEntity.Poll
|
||||
|
@ -222,6 +223,11 @@ namespace MisskeyAPI {
|
|||
unread: false
|
||||
}
|
||||
}
|
||||
|
||||
export const list = (l: Entity.List): MegalodonEntity.List => ({
|
||||
id: l.id,
|
||||
title: l.name
|
||||
})
|
||||
}
|
||||
|
||||
export const DEFAULT_SCOPE = [
|
||||
|
|
8
src/misskey/entities/list.ts
Normal file
8
src/misskey/entities/list.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace MisskeyEntity {
|
||||
export type List = {
|
||||
id: string
|
||||
createdAt: string
|
||||
name: string
|
||||
userIds: Array<string>
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
/// <reference path="entities/follower.ts" />
|
||||
/// <reference path="entities/following.ts" />
|
||||
/// <reference path="entities/followRequest.ts" />
|
||||
/// <reference path="entities/list.ts" />
|
||||
/// <reference path="entities/mute.ts" />
|
||||
/// <reference path="entities/note.ts" />
|
||||
/// <reference path="entities/poll.ts" />
|
||||
|
|
Loading…
Reference in a new issue