-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TalkBlockSession. This implement #85
Add blockUser to OpenChannelSession.
- Loading branch information
1 parent
2c2932a
commit 17e4734
Showing
9 changed files
with
138 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Created on Mon Feb 01 2021 | ||
* | ||
* Copyright (c) storycraft. Licensed under the MIT Licence. | ||
*/ | ||
|
||
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: TalkSession) { | ||
|
||
} | ||
|
||
/** | ||
* Block normal user | ||
* | ||
* @param user | ||
* @param type | ||
*/ | ||
async blockUser(user: ChannelUser, type: TalkBlockType = TalkBlockType.BLOCK): AsyncCommandResult { | ||
const res = await this._session.request( | ||
'BLADDITEM', | ||
{ | ||
'l': [user.userId], | ||
'ts': [type] | ||
} | ||
); | ||
|
||
return { success: res.status === KnownDataStatusCode.SUCCESS, status: res.status }; | ||
} | ||
|
||
/** | ||
* Block plus user | ||
* | ||
* @param plusUser | ||
* @param type | ||
*/ | ||
async blockPlusUser(plusUser: ChannelUser, type: TalkBlockType = TalkBlockType.BLOCK): AsyncCommandResult { | ||
const res = await this._session.request( | ||
'BLADDITEM', | ||
{ | ||
'pl': [plusUser.userId], | ||
'pts': [type] | ||
} | ||
); | ||
|
||
return { success: res.status === KnownDataStatusCode.SUCCESS, status: res.status }; | ||
} | ||
|
||
/** | ||
* Unblock normal user. | ||
* | ||
* @param user | ||
*/ | ||
async unblockUser(user: ChannelUser) { | ||
const res = await this._session.request( | ||
'BLDELITEM', | ||
{ | ||
'l': [user.userId], | ||
} | ||
); | ||
|
||
return { success: res.status === KnownDataStatusCode.SUCCESS, status: res.status }; | ||
} | ||
|
||
/** | ||
* Unblock plus user. | ||
* | ||
* @param plusUser | ||
*/ | ||
async unblockPlusUser(plusUser: ChannelUser) { | ||
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 | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters