mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-26 20:34:44 +01:00
Web Bots: Some fixes (#1873)
This commit is contained in:
parent
ccaa82bec1
commit
183a5fad5b
@ -10,6 +10,7 @@ import {
|
||||
} from '../../../config';
|
||||
import { callApi } from '../../../api/gramjs';
|
||||
import {
|
||||
selectBot,
|
||||
selectChat, selectChatBot, selectChatMessage, selectCurrentChat, selectCurrentMessageList,
|
||||
selectIsTrustedBot, selectReplyingToId, selectSendAs, selectUser,
|
||||
} from '../../selectors';
|
||||
@ -115,7 +116,7 @@ addActionHandler('clickBotInlineButton', (global, actions, payload) => {
|
||||
if (!chatId) {
|
||||
return;
|
||||
}
|
||||
const bot = selectChatBot(global, chatId);
|
||||
const bot = selectBot(global, chatId);
|
||||
if (!bot) {
|
||||
return;
|
||||
}
|
||||
@ -139,7 +140,7 @@ addActionHandler('clickBotInlineButton', (global, actions, payload) => {
|
||||
if (!message.viaBotId && !message.senderId) {
|
||||
return;
|
||||
}
|
||||
const bot = selectChatBot(global, message.viaBotId! || message.senderId!);
|
||||
const bot = selectBot(global, message.viaBotId! || message.senderId!);
|
||||
if (!bot) {
|
||||
return;
|
||||
}
|
||||
@ -459,12 +460,12 @@ addActionHandler('requestWebView', async (global, actions, payload) => {
|
||||
});
|
||||
});
|
||||
|
||||
addActionHandler('prolongWebView', (global, actions, payload) => {
|
||||
addActionHandler('prolongWebView', async (global, actions, payload) => {
|
||||
const {
|
||||
bot, peer, isSilent, replyToMessageId, queryId,
|
||||
} = payload;
|
||||
|
||||
const result = callApi('prolongWebView', {
|
||||
const result = await callApi('prolongWebView', {
|
||||
bot,
|
||||
peer,
|
||||
isSilent,
|
||||
|
@ -5,7 +5,7 @@ import { ApiError } from '../../../api/types';
|
||||
import { IS_SINGLE_COLUMN_LAYOUT, IS_TABLET_COLUMN_LAYOUT } from '../../../util/environment';
|
||||
import getReadableErrorText from '../../../util/getReadableErrorText';
|
||||
import {
|
||||
selectChatBot, selectChatMessage, selectCurrentMessageList, selectIsTrustedBot,
|
||||
selectBot, selectChatMessage, selectCurrentMessageList, selectIsTrustedBot,
|
||||
} from '../../selectors';
|
||||
import generateIdFor from '../../../util/generateIdFor';
|
||||
|
||||
@ -298,7 +298,7 @@ addActionHandler('openGame', (global, actions, payload) => {
|
||||
if (!message) return;
|
||||
|
||||
const botId = message.viaBotId || message.senderId;
|
||||
const bot = botId && selectChatBot(global, botId);
|
||||
const bot = botId && selectBot(global, botId);
|
||||
if (!bot) return;
|
||||
|
||||
if (!selectIsTrustedBot(global, bot)) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { GlobalState } from '../types';
|
||||
import { ApiChat, ApiUser, ApiUserStatus } from '../../api/types';
|
||||
import { isUserBot } from '../helpers';
|
||||
|
||||
export function selectUser(global: GlobalState, userId: string): ApiUser | undefined {
|
||||
return global.users.byId[userId];
|
||||
@ -33,3 +34,12 @@ export function selectUserByPhoneNumber(global: GlobalState, phoneNumber: string
|
||||
export function selectIsUserOrChatContact(global: GlobalState, userOrChat: ApiUser | ApiChat) {
|
||||
return global.contactList && global.contactList.userIds.includes(userOrChat.id);
|
||||
}
|
||||
|
||||
export function selectBot(global: GlobalState, userId: string): ApiUser | undefined {
|
||||
const user = selectUser(global, userId);
|
||||
if (!user || !isUserBot(user)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user