From 078297fc060aef7fa0c0170990688bab8659a99c Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Thu, 7 May 2026 19:39:40 +0800 Subject: [PATCH] chore: sync local changes --- xuqm-sdk/src/main/ets/core/Types.ets | 10 +-- xuqm-sdk/src/main/ets/im/ImClient.ets | 104 ++++++++++++------------- xuqm-sdk/src/main/ets/push/PushSDK.ets | 6 +- 3 files changed, 59 insertions(+), 61 deletions(-) diff --git a/xuqm-sdk/src/main/ets/core/Types.ets b/xuqm-sdk/src/main/ets/core/Types.ets index f8fafd4..dee1fa5 100644 --- a/xuqm-sdk/src/main/ets/core/Types.ets +++ b/xuqm-sdk/src/main/ets/core/Types.ets @@ -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 { 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 diff --git a/xuqm-sdk/src/main/ets/im/ImClient.ets b/xuqm-sdk/src/main/ets/im/ImClient.ets index 91f4cb4..05a332e 100644 --- a/xuqm-sdk/src/main/ets/im/ImClient.ets +++ b/xuqm-sdk/src/main/ets/im/ImClient.ets @@ -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 { const params = new DraftBody() - params.appId = SDKContext.getConfig().appKey + params.appKey = SDKContext.getConfig().appKey params.chatType = chatType params.draft = draft await HttpClient.put('/api/im/conversations/' + encodeURIComponent(targetId) + '/draft', params) @@ -298,7 +298,7 @@ export class ImClient { async setConversationPinned(targetId: string, chatType: ChatType, pinned: boolean): Promise { const params = new PinBody() - params.appId = SDKContext.getConfig().appKey + params.appKey = SDKContext.getConfig().appKey params.chatType = chatType params.pinned = pinned await HttpClient.put('/api/im/conversations/' + encodeURIComponent(targetId) + '/pinned', params) @@ -306,7 +306,7 @@ export class ImClient { async setConversationMuted(targetId: string, chatType: ChatType, muted: boolean): Promise { const params = new MuteBody() - params.appId = SDKContext.getConfig().appKey + params.appKey = SDKContext.getConfig().appKey params.chatType = chatType params.muted = muted await HttpClient.put('/api/im/conversations/' + encodeURIComponent(targetId) + '/muted', params) @@ -389,7 +389,7 @@ export class ImClient { async sendFriendRequest(toUserId: string, remark: string | null = null): Promise { 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 { 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 { 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 { const params = new AppBody() - params.appId = SDKContext.getConfig().appKey + params.appKey = SDKContext.getConfig().appKey await HttpClient.put('/api/im/conversations/' + encodeURIComponent(targetId) + '/hidden', params) } async setConversationGroup(targetId: string, groupName: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, groupName } + const params = { appKey: SDKContext.getConfig().appKey, groupName } await HttpClient.put('/api/im/conversations/' + encodeURIComponent(targetId) + '/group', params) } @@ -482,7 +482,7 @@ export class ImClient { /* ---------- 好友扩展 ---------- */ async addFriend(friendId: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, friendId } + const params = { appKey: SDKContext.getConfig().appKey, friendId } await HttpClient.post('/api/im/friends', params) } @@ -495,7 +495,7 @@ export class ImClient { } async setFriendGroup(friendId: string, groupName: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, groupName } + const params = { appKey: SDKContext.getConfig().appKey, groupName } await HttpClient.put('/api/im/friends/' + encodeURIComponent(friendId) + '/group', params) } @@ -508,7 +508,7 @@ export class ImClient { } async checkFriends(friendIds: string[]): Promise> { - const params = { appId: SDKContext.getConfig().appKey, friendIds } + const params = { appKey: SDKContext.getConfig().appKey, friendIds } return HttpClient.post>('/api/im/friends/check', params) } @@ -518,7 +518,7 @@ export class ImClient { } async addToBlacklist(userId: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, userId } + const params = { appKey: SDKContext.getConfig().appKey, userId } await HttpClient.post('/api/im/blacklist', params) } @@ -535,19 +535,19 @@ export class ImClient { /* ---------- 群组扩展 ---------- */ async createGroup(name: string, memberIds: string[], groupType: string = 'WORK'): Promise { - const params = { appId: SDKContext.getConfig().appKey, name, memberIds, groupType } + const params = { appKey: SDKContext.getConfig().appKey, name, memberIds, groupType } return HttpClient.post('/api/im/groups', params) } async updateGroupInfo(groupId: string, name?: string, announcement?: string): Promise { - const params: Record = { appId: SDKContext.getConfig().appKey } + const params: Record = { appKey: SDKContext.getConfig().appKey } if (name !== undefined) params.name = name if (announcement !== undefined) params.announcement = announcement return HttpClient.put('/api/im/groups/' + encodeURIComponent(groupId), params) } async addGroupMember(groupId: string, userId: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, userId } + const params = { appKey: SDKContext.getConfig().appKey, userId } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/members', params) } @@ -560,27 +560,27 @@ export class ImClient { } async setGroupRole(groupId: string, userId: string, role: 'ADMIN' | 'MEMBER'): Promise { - const params = { appId: SDKContext.getConfig().appKey, userId, role } + const params = { appKey: SDKContext.getConfig().appKey, userId, role } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/roles', params) } async muteGroupMember(groupId: string, userId: string, muted: boolean): Promise { - const params = { appId: SDKContext.getConfig().appKey, userId, muted } + const params = { appKey: SDKContext.getConfig().appKey, userId, muted } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/mute', params) } async transferGroupOwner(groupId: string, newOwnerId: string): Promise { - const params = { appId: SDKContext.getConfig().appKey, newOwnerId } + const params = { appKey: SDKContext.getConfig().appKey, newOwnerId } return HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/owner', params) } async updateGroupAttributes(groupId: string, attributes: Record): Promise { - const params = { appId: SDKContext.getConfig().appKey, attributes } + const params = { appKey: SDKContext.getConfig().appKey, attributes } await HttpClient.put('/api/im/groups/' + encodeURIComponent(groupId) + '/attributes', params) } async removeGroupAttributes(groupId: string, keys: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, keys } + const params = { appKey: SDKContext.getConfig().appKey, keys } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/attributes/delete', params) } @@ -590,47 +590,47 @@ export class ImClient { /* ---------- 批量操作 ---------- */ async batchAddFriends(friendIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, friendIds } + const params = { appKey: SDKContext.getConfig().appKey, friendIds } await HttpClient.post('/api/im/friends/batch', params) } async batchRemoveFriends(friendIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, friendIds } + const params = { appKey: SDKContext.getConfig().appKey, friendIds } await HttpClient.post('/api/im/friends/batch/remove', params) } async batchAcceptFriendRequests(requestIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, requestIds } + const params = { appKey: SDKContext.getConfig().appKey, requestIds } await HttpClient.post('/api/im/friend-requests/batch/accept', params) } async batchRejectFriendRequests(requestIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, requestIds } + const params = { appKey: SDKContext.getConfig().appKey, requestIds } await HttpClient.post('/api/im/friend-requests/batch/reject', params) } async batchAddMembers(groupId: string, userIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, userIds } + const params = { appKey: SDKContext.getConfig().appKey, userIds } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/members/batch', params) } async batchRemoveMembers(groupId: string, userIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, userIds } + const params = { appKey: SDKContext.getConfig().appKey, userIds } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/members/batch/remove', params) } async batchAcceptJoinRequests(groupId: string, requestIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, requestIds } + const params = { appKey: SDKContext.getConfig().appKey, requestIds } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/join-requests/batch/accept', params) } async batchRejectJoinRequests(groupId: string, requestIds: string[]): Promise { - const params = { appId: SDKContext.getConfig().appKey, requestIds } + const params = { appKey: SDKContext.getConfig().appKey, requestIds } await HttpClient.post('/api/im/groups/' + encodeURIComponent(groupId) + '/join-requests/batch/reject', params) } async modifyMemberInfo(groupId: string, userId: string, nickname?: string, role?: string): Promise { - const params: Record = { appId: SDKContext.getConfig().appKey } + const params: Record = { appKey: SDKContext.getConfig().appKey } if (nickname !== undefined) params.nickname = nickname if (role !== undefined) params.role = role await HttpClient.put('/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, diff --git a/xuqm-sdk/src/main/ets/push/PushSDK.ets b/xuqm-sdk/src/main/ets/push/PushSDK.ets index 8dce2c8..a09c0c2 100644 --- a/xuqm-sdk/src/main/ets/push/PushSDK.ets +++ b/xuqm-sdk/src/main/ets/push/PushSDK.ets @@ -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 { 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 {