feat(push-notifications): 新增更新令牌用户ID功能
添加新的API端点用于更新设备推送令牌绑定的用户ID,包括: - 新增UpdateTokenUserIdDto和UpdateTokenUserIdResponseDto - 在控制器中添加updateTokenUserId端点 - 在服务层实现updateTokenUserId方法 - 在push-token服务中添加底层更新逻辑 - 优化推送测试服务,仅在主进程中执行
This commit is contained in:
@@ -504,6 +504,34 @@ export class PushNotificationsService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新令牌绑定的用户ID
|
||||
*/
|
||||
async updateTokenUserId(userId: string, deviceToken: string): Promise<any> {
|
||||
try {
|
||||
const token = await this.pushTokenService.updateTokenUserId(deviceToken, userId);
|
||||
this.logger.log(`Updated user ID for device token: ${deviceToken}`);
|
||||
return {
|
||||
code: ResponseCode.SUCCESS,
|
||||
message: '令牌用户ID更新成功',
|
||||
data: {
|
||||
success: true,
|
||||
tokenId: token.id,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to update user ID for device token: ${error.message}`, error);
|
||||
return {
|
||||
code: ResponseCode.ERROR,
|
||||
message: `令牌用户ID更新失败: ${error.message}`,
|
||||
data: {
|
||||
success: false,
|
||||
tokenId: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于设备令牌发送推送通知
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user