Browse Source

Bot description video & photo

master
Eduard Kuzmenko 2 years ago
parent
commit
94d0414fb0
  1. 7
      src/components/chat/bubbles.ts
  2. 2
      src/components/wrappers/video.ts
  3. 2
      src/lib/appManagers/appPhotosManager.ts
  4. 8
      src/lib/appManagers/appProfileManager.ts
  5. 12
      src/lib/mtproto/referenceDatabase.ts
  6. 4
      src/scss/partials/_chatBubble.scss

7
src/components/chat/bubbles.ts

@ -3881,6 +3881,7 @@ export default class ChatBubbles { @@ -3881,6 +3881,7 @@ export default class ChatBubbles {
group: CHAT_ANIMATION_GROUP,
loadPromises,
autoDownload: this.chat.autoDownload,
noInfo: message.mid < 0
});
//}
} else {
@ -4084,6 +4085,7 @@ export default class ChatBubbles { @@ -4084,6 +4085,7 @@ export default class ChatBubbles {
useSearch: !(message as Message.message).pFlags.is_scheduled,
isScheduled: (message as Message.message).pFlags.is_scheduled
} : undefined,
noInfo: message.mid < 0
});
}
} else {
@ -5336,7 +5338,10 @@ export default class ChatBubbles { @@ -5336,7 +5338,10 @@ export default class ChatBubbles {
}
const message = await this.generateLocalFirstMessage(false, (message) => {
message.message = userFull.bot_info.description;
const botInfo = userFull.bot_info;
message.message = botInfo.description;
if(botInfo.description_document) message.media = {_: 'messageMediaDocument', document: botInfo.description_document};
if(botInfo.description_photo) message.media = {_: 'messageMediaPhoto', photo: botInfo.description_photo};
});
if(!middleware()) {

2
src/components/wrappers/video.ts

@ -68,7 +68,7 @@ export default async function wrapVideo({doc, container, message, boxWidth, boxH @@ -68,7 +68,7 @@ export default async function wrapVideo({doc, container, message, boxWidth, boxH
isOut?: boolean,
middleware?: () => boolean,
lazyLoadQueue?: LazyLoadQueue,
noInfo?: true,
noInfo?: boolean,
noPlayButton?: boolean,
group?: string,
onlyPreview?: boolean,

2
src/lib/appManagers/appPhotosManager.ts

@ -26,7 +26,7 @@ export class AppPhotosManager extends AppManager { @@ -26,7 +26,7 @@ export class AppPhotosManager extends AppManager {
} = {};
public savePhoto(photo: Photo, context?: ReferenceContext) {
if(photo._ === 'photoEmpty') return undefined;
if(!photo || photo._ === 'photoEmpty') return;
/* if(photo.id === TEST_FILE_REFERENCE) {
console.warn('Testing FILE_REFERENCE_EXPIRED');

8
src/lib/appManagers/appProfileManager.ts

@ -19,6 +19,7 @@ import getPeerId from "./utils/peers/getPeerId"; @@ -19,6 +19,7 @@ import getPeerId from "./utils/peers/getPeerId";
import getPhotoInput from "./utils/photos/getPhotoInput";
import getParticipantPeerId from "./utils/chats/getParticipantPeerId";
import ctx from "../../environment/ctx";
import { ReferenceContext } from "../mtproto/referenceDatabase";
export type UserTyping = Partial<{userId: UserId, action: SendMessageAction, timeout: number}>;
@ -180,6 +181,13 @@ export class AppProfileManager extends AppManager { @@ -180,6 +181,13 @@ export class AppProfileManager extends AppManager {
userFull.profile_photo = this.appPhotosManager.savePhoto(userFull.profile_photo, {type: 'profilePhoto', peerId});
}
const botInfo = userFull.bot_info;
if(botInfo) {
const referenceContext: ReferenceContext = {type: 'userFull', userId: id};
botInfo.description_document = this.appDocsManager.saveDoc(botInfo.description_document, referenceContext);
botInfo.description_photo = this.appPhotosManager.savePhoto(botInfo.description_photo, referenceContext);
}
this.appNotificationsManager.savePeerSettings({
peerId,
settings: userFull.notify_settings

12
src/lib/mtproto/referenceDatabase.ts

@ -10,7 +10,7 @@ import bytesToHex from "../../helpers/bytes/bytesToHex"; @@ -10,7 +10,7 @@ import bytesToHex from "../../helpers/bytes/bytesToHex";
import deepEqual from "../../helpers/object/deepEqual";
import { AppManager } from "../appManagers/manager";
export type ReferenceContext = ReferenceContext.referenceContextProfilePhoto | ReferenceContext.referenceContextMessage | ReferenceContext.referenceContextEmojiesSounds | ReferenceContext.referenceContextReactions;
export type ReferenceContext = ReferenceContext.referenceContextProfilePhoto | ReferenceContext.referenceContextMessage | ReferenceContext.referenceContextEmojiesSounds | ReferenceContext.referenceContextReactions | ReferenceContext.referenceContextUserFull;
export namespace ReferenceContext {
export type referenceContextProfilePhoto = {
type: 'profilePhoto',
@ -30,6 +30,11 @@ export namespace ReferenceContext { @@ -30,6 +30,11 @@ export namespace ReferenceContext {
export type referenceContextReactions = {
type: 'reactions'
};
export type referenceContextUserFull = {
type: 'userFull',
userId: UserId
};
}
export type ReferenceBytes = Photo.photo['file_reference'];
@ -139,6 +144,11 @@ export class ReferenceDatabase extends AppManager { @@ -139,6 +144,11 @@ export class ReferenceDatabase extends AppManager {
break;
}
case 'userFull': {
promise = Promise.resolve(this.appProfileManager.getProfile(context.userId, true));
break;
}
default: {
this.log.warn('refreshReference: not implemented context', context);
return Promise.reject();

4
src/scss/partials/_chatBubble.scss

@ -935,6 +935,10 @@ $bubble-beside-button-width: 38px; @@ -935,6 +935,10 @@ $bubble-beside-button-width: 38px;
flex: 1 1 auto;
}
.attachment {
pointer-events: none;
}
.bubble-content-wrapper {
max-width: 100%;
}

Loading…
Cancel
Save