global update and global fix
This commit is contained in:
@@ -23,6 +23,9 @@ import { ChatService } from './chat.service';
|
||||
import { PresenceService } from './presence.service';
|
||||
import { TotpService } from './totp.service';
|
||||
import { MessagingService } from '../infra/messaging.service';
|
||||
import { BotFatherService } from './bot/bot-father.service';
|
||||
import { BotApiService } from './bot/bot-api.service';
|
||||
import { BotInboundService } from './bot/bot-inbound.service';
|
||||
|
||||
@Controller()
|
||||
@UseFilters(new GrpcExceptionFilter())
|
||||
@@ -47,7 +50,10 @@ export class AuthGrpcController {
|
||||
private readonly chat: ChatService,
|
||||
private readonly presence: PresenceService,
|
||||
private readonly messaging: MessagingService,
|
||||
private readonly totp: TotpService
|
||||
private readonly totp: TotpService,
|
||||
private readonly botFather: BotFatherService,
|
||||
private readonly botApi: BotApiService,
|
||||
private readonly botInbound: BotInboundService
|
||||
) {}
|
||||
|
||||
@GrpcMethod('AuthService', 'Register')
|
||||
@@ -634,6 +640,16 @@ export class AuthGrpcController {
|
||||
return this.profile.getAccountDeletionStatus(command.userId);
|
||||
}
|
||||
|
||||
@GrpcMethod('ProfileService', 'SetE2EPublicKey')
|
||||
setE2EPublicKey(command: { userId: string; publicKey: string }) {
|
||||
return this.profile.setE2EPublicKey(command.userId, command.publicKey);
|
||||
}
|
||||
|
||||
@GrpcMethod('ProfileService', 'GetE2EPublicKey')
|
||||
getE2EPublicKey(command: { userId: string }) {
|
||||
return this.profile.getE2EPublicKey(command.userId);
|
||||
}
|
||||
|
||||
@GrpcMethod('DocumentsService', 'CreateDocument')
|
||||
createDocument(command: { userId: string; type: string; number: string; issuedAt?: string; expiresAt?: string; metadataJson?: string }) {
|
||||
return this.documents.create(command);
|
||||
@@ -875,6 +891,20 @@ export class AuthGrpcController {
|
||||
return this.presence.getFamilyPresence(command.requesterId, command.groupId);
|
||||
}
|
||||
|
||||
@GrpcMethod('FamilyService', 'AddBotFatherToFamily')
|
||||
async addBotFatherToFamily(command: { requesterId: string; groupId: string }) {
|
||||
const member = await this.family.addBotFatherToFamily(command.requesterId, command.groupId);
|
||||
await this.chat.syncFamilyChats(command.groupId);
|
||||
return member;
|
||||
}
|
||||
|
||||
@GrpcMethod('FamilyService', 'AddBotToFamily')
|
||||
async addBotToFamily(command: { requesterId: string; groupId: string; botId: string }) {
|
||||
const member = await this.family.addBotToFamily(command.requesterId, command.groupId, command.botId);
|
||||
await this.chat.syncFamilyChats(command.groupId);
|
||||
return member;
|
||||
}
|
||||
|
||||
@GrpcMethod('NotificationsService', 'ListNotifications')
|
||||
listNotifications(command: { userId: string; limit?: number; unreadOnly?: boolean }) {
|
||||
return this.notifications.list(command.userId, command.limit, command.unreadOnly);
|
||||
@@ -915,6 +945,11 @@ export class AuthGrpcController {
|
||||
return this.chat.createRoom(command.userId, command.groupId, command.name, command.memberUserIds ?? []);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'CreateE2ERoom')
|
||||
createE2EChatRoom(command: { userId: string; groupId: string; peerUserId: string }) {
|
||||
return this.chat.createE2ERoom(command.userId, command.groupId, command.peerUserId);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'UpdateRoomSettings')
|
||||
updateChatRoomSettings(command: { userId: string; roomId: string; name?: string; notificationsMuted?: boolean }) {
|
||||
return this.chat.updateRoomSettings(command.userId, command.roomId, command.name, command.notificationsMuted);
|
||||
@@ -946,6 +981,7 @@ export class AuthGrpcController {
|
||||
mimeType?: string;
|
||||
metadataJson?: string;
|
||||
poll?: { question: string; options: string[]; allowsMultiple?: boolean; isAnonymous?: boolean };
|
||||
isEncrypted?: boolean;
|
||||
}) {
|
||||
return this.chat.sendMessage(
|
||||
command.userId,
|
||||
@@ -956,7 +992,8 @@ export class AuthGrpcController {
|
||||
command.storageKey,
|
||||
command.mimeType,
|
||||
command.metadataJson,
|
||||
command.poll
|
||||
command.poll,
|
||||
command.isEncrypted
|
||||
);
|
||||
}
|
||||
|
||||
@@ -970,6 +1007,11 @@ export class AuthGrpcController {
|
||||
return this.chat.setRoomNotificationsMuted(command.userId, command.roomId, command.muted);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'DeleteRoom')
|
||||
deleteChatRoom(command: { userId: string; roomId: string }) {
|
||||
return this.chat.deleteRoom(command.userId, command.roomId);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'EditMessage')
|
||||
editChatMessage(command: { userId: string; messageId: string; content: string }) {
|
||||
return this.chat.editMessage(command.userId, command.messageId, command.content);
|
||||
@@ -980,11 +1022,145 @@ export class AuthGrpcController {
|
||||
return this.chat.deleteMessage(command.userId, command.messageId);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'ToggleMessageReaction')
|
||||
toggleMessageReaction(command: { userId: string; messageId: string; emoji: string }) {
|
||||
return this.chat.toggleMessageReaction(command.userId, command.messageId, command.emoji);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'ForwardMessages')
|
||||
forwardMessages(command: { userId: string; targetRoomId: string; messageIds: string[] }) {
|
||||
return this.chat.forwardMessages(command.userId, command.targetRoomId, command.messageIds ?? []);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'MarkRoomRead')
|
||||
markChatRoomRead(command: { userId: string; roomId: string; lastMessageId?: string }) {
|
||||
return this.chat.markRoomRead(command.userId, command.roomId, command.lastMessageId);
|
||||
}
|
||||
|
||||
@GrpcMethod('ChatService', 'ReportTyping')
|
||||
reportTyping(command: { userId: string; roomId: string }) {
|
||||
return this.chat.reportTyping(command.userId, command.roomId);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'CreateBot')
|
||||
createBot(command: { ownerId: string; name: string; username: string }) {
|
||||
return this.botFather.createBot(command.ownerId, command.name, command.username);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'RevokeBotToken')
|
||||
revokeBotToken(command: { requesterId: string; botId: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.revokeToken(command.requesterId, command.botId, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'SetBotWebApp')
|
||||
setBotWebApp(command: { requesterId: string; botId: string; webAppUrl?: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.setWebApp(command.requesterId, command.botId, command.webAppUrl, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ListMyBots')
|
||||
listMyBots(command: { ownerId: string }) {
|
||||
return this.botFather.listMyBots(command.ownerId);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'GetBot')
|
||||
getBot(command: { requesterId: string; botId: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.getBot(command.requesterId, command.botId, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'UpdateBot')
|
||||
updateBot(command: { requesterId: string; botId: string; name?: string; username?: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.updateBot(command.requesterId, command.botId, command, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'UpdateBotProfile')
|
||||
updateBotProfile(command: {
|
||||
requesterId: string;
|
||||
botId: string;
|
||||
description?: string;
|
||||
aboutText?: string;
|
||||
botPicUrl?: string;
|
||||
menuButtonJson?: string;
|
||||
menuButtonUrl?: string;
|
||||
menuButtonText?: string;
|
||||
isSuperAdmin?: boolean;
|
||||
}) {
|
||||
const patch: {
|
||||
description?: string | null;
|
||||
aboutText?: string | null;
|
||||
botPicUrl?: string | null;
|
||||
menuButton?: unknown;
|
||||
} = {
|
||||
description: command.description,
|
||||
aboutText: command.aboutText,
|
||||
botPicUrl: command.botPicUrl
|
||||
};
|
||||
|
||||
if (command.menuButtonJson !== undefined) {
|
||||
patch.menuButton = command.menuButtonJson.trim() ? command.menuButtonJson : { type: 'default' };
|
||||
} else if (command.menuButtonUrl !== undefined) {
|
||||
const url = command.menuButtonUrl.trim();
|
||||
patch.menuButton = url
|
||||
? command.menuButtonText?.trim()
|
||||
? `${url}|${command.menuButtonText.trim()}`
|
||||
: url
|
||||
: { type: 'default' };
|
||||
}
|
||||
|
||||
return this.botFather.updateBotProfile(command.requesterId, command.botId, patch, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'DeleteBot')
|
||||
deleteBot(command: { requesterId: string; botId: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.deleteBot(command.requesterId, command.botId, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ListAllBots')
|
||||
listAllBots(command: { requesterId: string; isSuperAdmin?: boolean; search?: string; page?: number; limit?: number }) {
|
||||
return this.botFather.listAllBots(command.requesterId, Boolean(command.isSuperAdmin), command.search, command.page, command.limit);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'SetBotActive')
|
||||
setBotActive(command: { requesterId: string; botId: string; isActive: boolean; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.setBotActive(command.requesterId, command.botId, command.isActive, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'GetBotMetrics')
|
||||
getBotMetrics(command: { requesterId: string; isSuperAdmin?: boolean }) {
|
||||
return this.botFather.getBotMetrics(command.requesterId, Boolean(command.isSuperAdmin));
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ValidateBotToken')
|
||||
async validateBotToken(command: { token: string }) {
|
||||
const bot = await this.botFather.validateBotToken(command.token);
|
||||
return bot ?? {};
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ExecuteBotMethod')
|
||||
executeBotMethod(command: { token: string; method: string; payloadJson: string }) {
|
||||
const payload = command.payloadJson ? (JSON.parse(command.payloadJson) as Record<string, unknown>) : {};
|
||||
return this.botApi.executeMethod(command.token, command.method, payload);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ValidateWebAppInitData')
|
||||
validateWebAppInitData(command: { initData: string; botToken: string }) {
|
||||
return this.botApi.validateWebAppInitData(command.initData, command.botToken);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'SubmitBotInboundMessage')
|
||||
submitBotInboundMessage(command: { senderUserId: string; botRef: string; text: string }) {
|
||||
return this.botInbound.submitUserMessage(command.senderUserId, command.botRef, command.text);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'SubmitBotCallbackQuery')
|
||||
submitBotCallbackQuery(command: { senderUserId: string; botRef: string; messageId: number; callbackData: string }) {
|
||||
return this.botInbound.submitCallbackQuery(command.senderUserId, command.botRef, command.messageId, command.callbackData);
|
||||
}
|
||||
|
||||
@GrpcMethod('BotService', 'ListBotChatMessages')
|
||||
listBotChatMessages(command: { userId: string; botRef: string }) {
|
||||
return this.botApi.listBotChatMessages(command.userId, command.botRef);
|
||||
}
|
||||
|
||||
private toSessionResponse(session: { id: string; userId: string; deviceId: string | null; pinVerified: boolean; status: string; ipAddress: string | null; userAgent: string | null; expiresAt: Date; createdAt: Date; updatedAt: Date }) {
|
||||
return {
|
||||
id: session.id,
|
||||
|
||||
Reference in New Issue
Block a user