chore: sync local changes
这个提交包含在:
父节点
6c11380a36
当前提交
078297fc06
@ -38,7 +38,7 @@ export type MsgStatus = 'SENDING' | 'SENT' | 'DELIVERED' | 'READ' | 'FAILED' | '
|
||||
|
||||
export interface ImMessage {
|
||||
id: string
|
||||
appId: string
|
||||
appKey: string
|
||||
fromUserId: string
|
||||
fromId: string
|
||||
toId: string
|
||||
@ -86,7 +86,7 @@ export interface PageResult<T> {
|
||||
|
||||
export interface UserProfile {
|
||||
id?: string
|
||||
appId?: string
|
||||
appKey?: string
|
||||
userId: string
|
||||
nickname?: string | null
|
||||
avatar?: string | null
|
||||
@ -97,7 +97,7 @@ export interface UserProfile {
|
||||
|
||||
export interface ImGroup {
|
||||
id: string
|
||||
appId?: string
|
||||
appKey?: string
|
||||
name: string
|
||||
groupType?: string
|
||||
creatorId: string
|
||||
@ -109,7 +109,7 @@ export interface ImGroup {
|
||||
|
||||
export interface FriendRequest {
|
||||
id: string
|
||||
appId?: string
|
||||
appKey?: string
|
||||
fromUserId: string
|
||||
toUserId: string
|
||||
remark?: string | null
|
||||
@ -120,7 +120,7 @@ export interface FriendRequest {
|
||||
|
||||
export interface GroupJoinRequest {
|
||||
id: string
|
||||
appId?: string
|
||||
appKey?: string
|
||||
groupId: string
|
||||
requesterId: string
|
||||
remark?: string | null
|
||||
|
||||
@ -43,11 +43,11 @@ class WebSocketEnvelope {
|
||||
}
|
||||
|
||||
class AppBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
}
|
||||
|
||||
class HistoryQueryParams {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
page: number = 0
|
||||
size: number = 0
|
||||
msgType: MsgType = 'TEXT'
|
||||
@ -57,23 +57,23 @@ class HistoryQueryParams {
|
||||
}
|
||||
|
||||
class ConversationActionBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
chatType: ChatType = 'SINGLE'
|
||||
}
|
||||
|
||||
class FriendRequestQueryBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
direction: 'incoming' | 'outgoing' = 'incoming'
|
||||
}
|
||||
|
||||
class FriendRequestBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
toUserId: string = ''
|
||||
remark: string = ''
|
||||
}
|
||||
|
||||
class GroupJoinRequestBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
remark: string = ''
|
||||
}
|
||||
|
||||
@ -82,26 +82,26 @@ class EditMessageBody {
|
||||
}
|
||||
|
||||
class UpdateProfileBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
nickname: string = ''
|
||||
avatar: string = ''
|
||||
gender: string = ''
|
||||
}
|
||||
|
||||
class DraftBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
chatType: ChatType = 'SINGLE'
|
||||
draft: string = ''
|
||||
}
|
||||
|
||||
class PinBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
chatType: ChatType = 'SINGLE'
|
||||
pinned: boolean = false
|
||||
}
|
||||
|
||||
class MuteBody {
|
||||
appId: string = ''
|
||||
appKey: string = ''
|
||||
chatType: ChatType = 'SINGLE'
|
||||
muted: boolean = false
|
||||
}
|
||||
@ -290,7 +290,7 @@ export class ImClient {
|
||||
|
||||
async setDraft(targetId: string, chatType: ChatType, draft: string): Promise<void> {
|
||||
const params = new DraftBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
params.chatType = chatType
|
||||
params.draft = draft
|
||||
await HttpClient.put<void>('/api/im/conversations/' + encodeURIComponent(targetId) + '/draft', params)
|
||||
@ -298,7 +298,7 @@ export class ImClient {
|
||||
|
||||
async setConversationPinned(targetId: string, chatType: ChatType, pinned: boolean): Promise<void> {
|
||||
const params = new PinBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
params.chatType = chatType
|
||||
params.pinned = pinned
|
||||
await HttpClient.put<void>('/api/im/conversations/' + encodeURIComponent(targetId) + '/pinned', params)
|
||||
@ -306,7 +306,7 @@ export class ImClient {
|
||||
|
||||
async setConversationMuted(targetId: string, chatType: ChatType, muted: boolean): Promise<void> {
|
||||
const params = new MuteBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
params.chatType = chatType
|
||||
params.muted = muted
|
||||
await HttpClient.put<void>('/api/im/conversations/' + encodeURIComponent(targetId) + '/muted', params)
|
||||
@ -389,7 +389,7 @@ export class ImClient {
|
||||
|
||||
async sendFriendRequest(toUserId: string, remark: string | null = null): Promise<FriendRequest> {
|
||||
const params = new FriendRequestBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
params.toUserId = toUserId
|
||||
if (remark !== null && remark !== '') {
|
||||
params.remark = remark
|
||||
@ -411,7 +411,7 @@ export class ImClient {
|
||||
|
||||
async sendGroupJoinRequest(groupId: string, remark: string | null = null): Promise<GroupJoinRequest> {
|
||||
const params = new GroupJoinRequestBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
if (remark !== null && remark !== '') {
|
||||
params.remark = remark
|
||||
}
|
||||
@ -447,7 +447,7 @@ export class ImClient {
|
||||
gender: string | null = null,
|
||||
): Promise<UserProfile> {
|
||||
const params = new UpdateProfileBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
if (nickname !== null) {
|
||||
params.nickname = nickname
|
||||
}
|
||||
@ -463,12 +463,12 @@ export class ImClient {
|
||||
/* ---------- 会话扩展 ---------- */
|
||||
async setConversationHidden(targetId: string, hidden: boolean): Promise<void> {
|
||||
const params = new AppBody()
|
||||
params.appId = SDKContext.getConfig().appKey
|
||||
params.appKey = SDKContext.getConfig().appKey
|
||||
await HttpClient.put<void>('/api/im/conversations/' + encodeURIComponent(targetId) + '/hidden', params)
|
||||
}
|
||||
|
||||
async setConversationGroup(targetId: string, groupName: string): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, groupName }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, groupName }
|
||||
await HttpClient.put<void>('/api/im/conversations/' + encodeURIComponent(targetId) + '/group', params)
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ export class ImClient {
|
||||
|
||||
/* ---------- 好友扩展 ---------- */
|
||||
async addFriend(friendId: string): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, friendId }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, friendId }
|
||||
await HttpClient.post<void>('/api/im/friends', params)
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ export class ImClient {
|
||||
}
|
||||
|
||||
async setFriendGroup(friendId: string, groupName: string): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, groupName }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, groupName }
|
||||
await HttpClient.put<void>('/api/im/friends/' + encodeURIComponent(friendId) + '/group', params)
|
||||
}
|
||||
|
||||
@ -508,7 +508,7 @@ export class ImClient {
|
||||
}
|
||||
|
||||
async checkFriends(friendIds: string[]): Promise<Record<string, boolean>> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, friendIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, friendIds }
|
||||
return HttpClient.post<Record<string, boolean>>('/api/im/friends/check', params)
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ export class ImClient {
|
||||
}
|
||||
|
||||
async addToBlacklist(userId: string): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userId }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userId }
|
||||
await HttpClient.post<void>('/api/im/blacklist', params)
|
||||
}
|
||||
|
||||
@ -535,19 +535,19 @@ export class ImClient {
|
||||
|
||||
/* ---------- 群组扩展 ---------- */
|
||||
async createGroup(name: string, memberIds: string[], groupType: string = 'WORK'): Promise<ImGroup> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, name, memberIds, groupType }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, name, memberIds, groupType }
|
||||
return HttpClient.post<ImGroup>('/api/im/groups', params)
|
||||
}
|
||||
|
||||
async updateGroupInfo(groupId: string, name?: string, announcement?: string): Promise<ImGroup> {
|
||||
const params: Record<string, string> = { appId: SDKContext.getConfig().appKey }
|
||||
const params: Record<string, string> = { appKey: SDKContext.getConfig().appKey }
|
||||
if (name !== undefined) params.name = name
|
||||
if (announcement !== undefined) params.announcement = announcement
|
||||
return HttpClient.put<ImGroup>('/api/im/groups/' + encodeURIComponent(groupId), params)
|
||||
}
|
||||
|
||||
async addGroupMember(groupId: string, userId: string): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userId }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userId }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/members', params)
|
||||
}
|
||||
|
||||
@ -560,27 +560,27 @@ export class ImClient {
|
||||
}
|
||||
|
||||
async setGroupRole(groupId: string, userId: string, role: 'ADMIN' | 'MEMBER'): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userId, role }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userId, role }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/roles', params)
|
||||
}
|
||||
|
||||
async muteGroupMember(groupId: string, userId: string, muted: boolean): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userId, muted }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userId, muted }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/mute', params)
|
||||
}
|
||||
|
||||
async transferGroupOwner(groupId: string, newOwnerId: string): Promise<ImGroup> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, newOwnerId }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, newOwnerId }
|
||||
return HttpClient.post<ImGroup>('/api/im/groups/' + encodeURIComponent(groupId) + '/owner', params)
|
||||
}
|
||||
|
||||
async updateGroupAttributes(groupId: string, attributes: Record<string, string | number | boolean | null>): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, attributes }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, attributes }
|
||||
await HttpClient.put<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/attributes', params)
|
||||
}
|
||||
|
||||
async removeGroupAttributes(groupId: string, keys: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, keys }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, keys }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/attributes/delete', params)
|
||||
}
|
||||
|
||||
@ -590,47 +590,47 @@ export class ImClient {
|
||||
|
||||
/* ---------- 批量操作 ---------- */
|
||||
async batchAddFriends(friendIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, friendIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, friendIds }
|
||||
await HttpClient.post<void>('/api/im/friends/batch', params)
|
||||
}
|
||||
|
||||
async batchRemoveFriends(friendIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, friendIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, friendIds }
|
||||
await HttpClient.post<void>('/api/im/friends/batch/remove', params)
|
||||
}
|
||||
|
||||
async batchAcceptFriendRequests(requestIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, requestIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, requestIds }
|
||||
await HttpClient.post<void>('/api/im/friend-requests/batch/accept', params)
|
||||
}
|
||||
|
||||
async batchRejectFriendRequests(requestIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, requestIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, requestIds }
|
||||
await HttpClient.post<void>('/api/im/friend-requests/batch/reject', params)
|
||||
}
|
||||
|
||||
async batchAddMembers(groupId: string, userIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userIds }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/members/batch', params)
|
||||
}
|
||||
|
||||
async batchRemoveMembers(groupId: string, userIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, userIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, userIds }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/members/batch/remove', params)
|
||||
}
|
||||
|
||||
async batchAcceptJoinRequests(groupId: string, requestIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, requestIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, requestIds }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/join-requests/batch/accept', params)
|
||||
}
|
||||
|
||||
async batchRejectJoinRequests(groupId: string, requestIds: string[]): Promise<void> {
|
||||
const params = { appId: SDKContext.getConfig().appKey, requestIds }
|
||||
const params = { appKey: SDKContext.getConfig().appKey, requestIds }
|
||||
await HttpClient.post<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/join-requests/batch/reject', params)
|
||||
}
|
||||
|
||||
async modifyMemberInfo(groupId: string, userId: string, nickname?: string, role?: string): Promise<void> {
|
||||
const params: Record<string, string> = { appId: SDKContext.getConfig().appKey }
|
||||
const params: Record<string, string> = { appKey: SDKContext.getConfig().appKey }
|
||||
if (nickname !== undefined) params.nickname = nickname
|
||||
if (role !== undefined) params.role = role
|
||||
await HttpClient.put<void>('/api/im/groups/' + encodeURIComponent(groupId) + '/members/' + encodeURIComponent(userId) + '/info', params)
|
||||
@ -638,28 +638,28 @@ export class ImClient {
|
||||
|
||||
private buildAppBody(): AppBody {
|
||||
const body = new AppBody()
|
||||
body.appId = SDKContext.getConfig().appKey
|
||||
body.appKey = SDKContext.getConfig().appKey
|
||||
return body
|
||||
}
|
||||
|
||||
private buildAppQuery(): string {
|
||||
return 'appId=' + encodeURIComponent(SDKContext.getConfig().appKey)
|
||||
return 'appKey=' + encodeURIComponent(SDKContext.getConfig().appKey)
|
||||
}
|
||||
|
||||
private buildConversationActionQuery(chatType: ChatType): string {
|
||||
return 'appId=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&chatType=' + encodeURIComponent(chatType)
|
||||
return 'appKey=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&chatType=' + encodeURIComponent(chatType)
|
||||
}
|
||||
|
||||
private buildConversationQuery(size: number): string {
|
||||
return 'appId=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&page=0&size=' + encodeURIComponent(size)
|
||||
return 'appKey=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&page=0&size=' + encodeURIComponent(size)
|
||||
}
|
||||
|
||||
private buildFriendRequestQuery(direction: 'incoming' | 'outgoing'): string {
|
||||
return 'appId=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&direction=' + encodeURIComponent(direction)
|
||||
return 'appKey=' + encodeURIComponent(SDKContext.getConfig().appKey) + '&direction=' + encodeURIComponent(direction)
|
||||
}
|
||||
|
||||
private buildSearchQuery(keyword: string, size: number): string {
|
||||
return 'appId=' + encodeURIComponent(SDKContext.getConfig().appKey) +
|
||||
return 'appKey=' + encodeURIComponent(SDKContext.getConfig().appKey) +
|
||||
'&keyword=' + encodeURIComponent(keyword) +
|
||||
'&size=' + encodeURIComponent(size)
|
||||
}
|
||||
@ -672,7 +672,7 @@ export class ImClient {
|
||||
size: number,
|
||||
): string {
|
||||
const parts: string[] = []
|
||||
parts.push('appId=' + encodeURIComponent(SDKContext.getConfig().appKey))
|
||||
parts.push('appKey=' + encodeURIComponent(SDKContext.getConfig().appKey))
|
||||
if (keyword !== '') {
|
||||
parts.push('keyword=' + encodeURIComponent(keyword))
|
||||
}
|
||||
@ -689,7 +689,7 @@ export class ImClient {
|
||||
|
||||
private buildHistoryQuery(page: number, size: number, query: HistoryQuery): string {
|
||||
const parts: string[] = []
|
||||
parts.push('appId=' + encodeURIComponent(SDKContext.getConfig().appKey))
|
||||
parts.push('appKey=' + encodeURIComponent(SDKContext.getConfig().appKey))
|
||||
parts.push('page=' + encodeURIComponent(page))
|
||||
parts.push('size=' + encodeURIComponent(size))
|
||||
if (query.msgType !== undefined) {
|
||||
@ -806,11 +806,10 @@ export class ImClient {
|
||||
private buildOutgoingMessage(params: SendMessageParams): ImMessage {
|
||||
const messageId = params.messageId ?? this.generateMessageId()
|
||||
const userId = SDKContext.getUserId() ?? ''
|
||||
const appId = SDKContext.getConfig().appKey
|
||||
const appKey = SDKContext.getConfig().appKey
|
||||
const message: ImMessage = {
|
||||
id: messageId,
|
||||
appId,
|
||||
fromUserId: userId,
|
||||
appKey, fromUserId: userId,
|
||||
fromId: userId,
|
||||
toId: params.toId,
|
||||
chatType: params.chatType,
|
||||
@ -828,8 +827,7 @@ export class ImClient {
|
||||
private markFailed(message: ImMessage): ImMessage {
|
||||
const failed: ImMessage = {
|
||||
id: message.id,
|
||||
appId: message.appId,
|
||||
fromUserId: message.fromUserId,
|
||||
appKey: message.appKey, fromUserId: message.fromUserId,
|
||||
fromId: message.fromId,
|
||||
toId: message.toId,
|
||||
chatType: message.chatType,
|
||||
@ -847,7 +845,7 @@ export class ImClient {
|
||||
private normalizeMessage(message: ImMessage): ImMessage {
|
||||
const normalized: ImMessage = {
|
||||
id: message.id,
|
||||
appId: message.appId || SDKContext.getConfig().appKey,
|
||||
appKey: message.appKey || SDKContext.getConfig().appKey,
|
||||
fromUserId: message.fromUserId,
|
||||
fromId: message.fromId || message.fromUserId,
|
||||
toId: message.toId,
|
||||
|
||||
@ -72,7 +72,7 @@ export class PushSDK {
|
||||
return
|
||||
}
|
||||
const query = PushSDK.queryString([
|
||||
new QueryItem('appId', config.appKey),
|
||||
new QueryItem('appKey', config.appKey),
|
||||
new QueryItem('userId', userId),
|
||||
new QueryItem('vendor', HARMONY_PUSH_VENDOR),
|
||||
new QueryItem('token', token),
|
||||
@ -96,7 +96,7 @@ export class PushSDK {
|
||||
static async unregisterToken(imUserId: string): Promise<void> {
|
||||
const config = SDKContext.getConfig()
|
||||
const query = PushSDK.queryString([
|
||||
new QueryItem('appId', config.appKey),
|
||||
new QueryItem('appKey', config.appKey),
|
||||
new QueryItem('userId', imUserId),
|
||||
new QueryItem('vendor', HARMONY_PUSH_VENDOR),
|
||||
new QueryItem('platform', HARMONY_PLATFORM),
|
||||
@ -111,7 +111,7 @@ export class PushSDK {
|
||||
}
|
||||
const config = SDKContext.getConfig()
|
||||
const query = PushSDK.queryString([
|
||||
new QueryItem('appId', config.appKey),
|
||||
new QueryItem('appKey', config.appKey),
|
||||
new QueryItem('platform', HARMONY_PLATFORM),
|
||||
])
|
||||
try {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户