import { AsyncCommandResult , KnownDataStatusCode } from '../../request' ; import { ChannelUser } from '../../user' ; import { TalkSession } from '../client' ; /**
 * Provide user block / unblock api.
 * Note: To get block list use web api.
 */ export class TalkBlockSession { constructor ( private _session ) { } param { ChannelUser } user param { TalkBlockType } type async blockUser ( user , type = TalkBlockType . BLOCK ) { const res = await this . _session . request ( 'BLADDITEM' , { 'l' : [ user . userId ] , 'ts' : [ type ] , } ) ; return { success : res . status === KnownDataStatusCode . SUCCESS , status : res . status } ; } param { ChannelUser } plusUser param { TalkBlockType } type async blockPlusUser ( plusUser , type = TalkBlockType . BLOCK ) { const res = await this . _session . request ( 'BLADDITEM' , { 'pl' : [ plusUser . userId ] , 'pts' : [ type ] , } ) ; return { success : res . status === KnownDataStatusCode . SUCCESS , status : res . status } ; } param { ChannelUser } user async unblockUser ( user ) { const res = await this . _session . request ( 'BLDELITEM' , { 'l' : [ user . userId ] , } ) ; return { success : res . status === KnownDataStatusCode . SUCCESS , status : res . status } ; } param { ChannelUser } plusUser async unblockPlusUser ( plusUser ) { const res = await this . _session . request ( 'BLDELITEM' , { 'pl' : [ plusUser . userId ] , } ) ; return { success : res . status === KnownDataStatusCode . SUCCESS , status : res . status } ; } } export enum TalkBlockType { BLOCK = 0 , BLOCK_HIDE_PROFILE = 1 }