はじまりの大地
このコミットが含まれているのは:
@@ -0,0 +1,228 @@
|
||||
import { pick } from '@peertube/peertube-core-utils'
|
||||
import {
|
||||
AbuseFilter,
|
||||
AbuseMessage,
|
||||
AbusePredefinedReasonsString,
|
||||
AbuseStateType,
|
||||
AbuseUpdate,
|
||||
AbuseVideoIs,
|
||||
AdminAbuse,
|
||||
HttpStatusCode,
|
||||
ResultList,
|
||||
UserAbuse
|
||||
} from '@peertube/peertube-models'
|
||||
import { unwrapBody } from '../requests/requests.js'
|
||||
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
|
||||
|
||||
export class AbusesCommand extends AbstractCommand {
|
||||
|
||||
report (options: OverrideCommandOptions & {
|
||||
reason: string
|
||||
|
||||
accountId?: number
|
||||
videoId?: number
|
||||
commentId?: number
|
||||
|
||||
predefinedReasons?: AbusePredefinedReasonsString[]
|
||||
|
||||
startAt?: number
|
||||
endAt?: number
|
||||
}) {
|
||||
const path = '/api/v1/abuses'
|
||||
|
||||
const video = options.videoId
|
||||
? {
|
||||
id: options.videoId,
|
||||
startAt: options.startAt,
|
||||
endAt: options.endAt
|
||||
}
|
||||
: undefined
|
||||
|
||||
const comment = options.commentId
|
||||
? { id: options.commentId }
|
||||
: undefined
|
||||
|
||||
const account = options.accountId
|
||||
? { id: options.accountId }
|
||||
: undefined
|
||||
|
||||
const body = {
|
||||
account,
|
||||
video,
|
||||
comment,
|
||||
|
||||
reason: options.reason,
|
||||
predefinedReasons: options.predefinedReasons
|
||||
}
|
||||
|
||||
return unwrapBody<{ abuse: { id: number } }>(this.postBodyRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
fields: body,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
}))
|
||||
}
|
||||
|
||||
getAdminList (options: OverrideCommandOptions & {
|
||||
start?: number
|
||||
count?: number
|
||||
sort?: string
|
||||
|
||||
id?: number
|
||||
predefinedReason?: AbusePredefinedReasonsString
|
||||
search?: string
|
||||
filter?: AbuseFilter
|
||||
state?: AbuseStateType
|
||||
videoIs?: AbuseVideoIs
|
||||
searchReporter?: string
|
||||
searchReportee?: string
|
||||
searchVideo?: string
|
||||
searchVideoChannel?: string
|
||||
} = {}) {
|
||||
const toPick: (keyof typeof options)[] = [
|
||||
'count',
|
||||
'filter',
|
||||
'id',
|
||||
'predefinedReason',
|
||||
'search',
|
||||
'searchReportee',
|
||||
'searchReporter',
|
||||
'searchVideo',
|
||||
'searchVideoChannel',
|
||||
'sort',
|
||||
'start',
|
||||
'state',
|
||||
'videoIs'
|
||||
]
|
||||
|
||||
const path = '/api/v1/abuses'
|
||||
|
||||
const defaultQuery = { sort: 'createdAt' }
|
||||
const query = { ...defaultQuery, ...pick(options, toPick) }
|
||||
|
||||
return this.getRequestBody<ResultList<AdminAbuse>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
query,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
getUserList (options: OverrideCommandOptions & {
|
||||
start?: number
|
||||
count?: number
|
||||
sort?: string
|
||||
|
||||
id?: number
|
||||
search?: string
|
||||
state?: AbuseStateType
|
||||
}) {
|
||||
const toPick: (keyof typeof options)[] = [
|
||||
'id',
|
||||
'search',
|
||||
'state',
|
||||
'start',
|
||||
'count',
|
||||
'sort'
|
||||
]
|
||||
|
||||
const path = '/api/v1/users/me/abuses'
|
||||
|
||||
const defaultQuery = { sort: 'createdAt' }
|
||||
const query = { ...defaultQuery, ...pick(options, toPick) }
|
||||
|
||||
return this.getRequestBody<ResultList<UserAbuse>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
query,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
update (options: OverrideCommandOptions & {
|
||||
abuseId: number
|
||||
body: AbuseUpdate
|
||||
}) {
|
||||
const { abuseId, body } = options
|
||||
const path = '/api/v1/abuses/' + abuseId
|
||||
|
||||
return this.putBodyRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
fields: body,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
delete (options: OverrideCommandOptions & {
|
||||
abuseId: number
|
||||
}) {
|
||||
const { abuseId } = options
|
||||
const path = '/api/v1/abuses/' + abuseId
|
||||
|
||||
return this.deleteRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
listMessages (options: OverrideCommandOptions & {
|
||||
abuseId: number
|
||||
}) {
|
||||
const { abuseId } = options
|
||||
const path = '/api/v1/abuses/' + abuseId + '/messages'
|
||||
|
||||
return this.getRequestBody<ResultList<AbuseMessage>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
deleteMessage (options: OverrideCommandOptions & {
|
||||
abuseId: number
|
||||
messageId: number
|
||||
}) {
|
||||
const { abuseId, messageId } = options
|
||||
const path = '/api/v1/abuses/' + abuseId + '/messages/' + messageId
|
||||
|
||||
return this.deleteRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
addMessage (options: OverrideCommandOptions & {
|
||||
abuseId: number
|
||||
message: string
|
||||
}) {
|
||||
const { abuseId, message } = options
|
||||
const path = '/api/v1/abuses/' + abuseId + '/messages'
|
||||
|
||||
return this.postBodyRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
fields: { message },
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { pick } from '@peertube/peertube-core-utils'
|
||||
import {
|
||||
AutomaticTagAvailable,
|
||||
CommentAutomaticTagPolicies,
|
||||
CommentAutomaticTagPoliciesUpdate,
|
||||
HttpStatusCode
|
||||
} from '@peertube/peertube-models'
|
||||
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
|
||||
|
||||
export class AutomaticTagsCommand extends AbstractCommand {
|
||||
|
||||
getCommentPolicies (options: OverrideCommandOptions & {
|
||||
accountName: string
|
||||
}) {
|
||||
const path = '/api/v1/automatic-tags/policies/accounts/' + options.accountName + '/comments'
|
||||
|
||||
return this.getRequestBody<CommentAutomaticTagPolicies>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
updateCommentPolicies (options: OverrideCommandOptions & CommentAutomaticTagPoliciesUpdate & {
|
||||
accountName: string
|
||||
}) {
|
||||
const path = '/api/v1/automatic-tags/policies/accounts/' + options.accountName + '/comments'
|
||||
|
||||
return this.putBodyRequest({
|
||||
...options,
|
||||
|
||||
path,
|
||||
fields: pick(options, [ 'review' ]),
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
getAccountAvailable (options: OverrideCommandOptions & {
|
||||
accountName: string
|
||||
}) {
|
||||
const path = '/api/v1/automatic-tags/accounts/' + options.accountName + '/available'
|
||||
|
||||
return this.getRequestBody<AutomaticTagAvailable>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
getServerAvailable (options: OverrideCommandOptions = {}) {
|
||||
const path = '/api/v1/automatic-tags/server/available'
|
||||
|
||||
return this.getRequestBody<AutomaticTagAvailable>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './abuses-command.js'
|
||||
export * from './automatic-tags-command.js'
|
||||
export * from './watched-words-command.js'
|
||||
@@ -0,0 +1,87 @@
|
||||
import { pick } from '@peertube/peertube-core-utils'
|
||||
import {
|
||||
HttpStatusCode,
|
||||
ResultList, WatchedWordsList
|
||||
} from '@peertube/peertube-models'
|
||||
import { unwrapBody } from '../index.js'
|
||||
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
|
||||
|
||||
export class WatchedWordsCommand extends AbstractCommand {
|
||||
|
||||
listWordsLists (options: OverrideCommandOptions & {
|
||||
start?: number
|
||||
count?: number
|
||||
sort?: string
|
||||
|
||||
accountName?: string
|
||||
}) {
|
||||
const query = {
|
||||
sort: '-createdAt',
|
||||
|
||||
...pick(options, [ 'start', 'count', 'sort' ])
|
||||
}
|
||||
|
||||
return this.getRequestBody<ResultList<WatchedWordsList>>({
|
||||
...options,
|
||||
|
||||
path: this.buildAPIBasePath(options.accountName),
|
||||
query,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
createList (options: OverrideCommandOptions & {
|
||||
listName: string
|
||||
words: string[]
|
||||
accountName?: string
|
||||
}) {
|
||||
const body = pick(options, [ 'listName', 'words' ])
|
||||
|
||||
return unwrapBody<{ watchedWordsList: { id: number } }>(this.postBodyRequest({
|
||||
...options,
|
||||
|
||||
path: this.buildAPIBasePath(options.accountName),
|
||||
fields: body,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
}))
|
||||
}
|
||||
|
||||
updateList (options: OverrideCommandOptions & {
|
||||
listId: number
|
||||
accountName?: string
|
||||
listName?: string
|
||||
words?: string[]
|
||||
}) {
|
||||
const body = pick(options, [ 'listName', 'words' ])
|
||||
|
||||
return this.putBodyRequest({
|
||||
...options,
|
||||
|
||||
path: this.buildAPIBasePath(options.accountName) + '/' + options.listId,
|
||||
fields: body,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
deleteList (options: OverrideCommandOptions & {
|
||||
listId: number
|
||||
accountName?: string
|
||||
}) {
|
||||
return this.deleteRequest({
|
||||
...options,
|
||||
|
||||
path: this.buildAPIBasePath(options.accountName) + '/' + options.listId,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||
})
|
||||
}
|
||||
|
||||
private buildAPIBasePath (accountName?: string) {
|
||||
return accountName
|
||||
? '/api/v1/watched-words/accounts/' + accountName + '/lists'
|
||||
: '/api/v1/watched-words/server/lists'
|
||||
}
|
||||
}
|
||||
新しい課題から参照
ユーザをブロックする