api_chat_invite.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/layers/box_content.h"
  9. class UserData;
  10. class ChannelData;
  11. namespace Info::Profile {
  12. class Badge;
  13. enum class BadgeType;
  14. } // namespace Info::Profile
  15. namespace Main {
  16. class Session;
  17. } // namespace Main
  18. namespace Window {
  19. class SessionController;
  20. } // namespace Window
  21. namespace Data {
  22. class PhotoMedia;
  23. } // namespace Data
  24. namespace Ui {
  25. class EmptyUserpic;
  26. } // namespace Ui
  27. namespace Api {
  28. void CheckChatInvite(
  29. not_null<Window::SessionController*> controller,
  30. const QString &hash,
  31. ChannelData *invitePeekChannel = nullptr,
  32. Fn<void()> loaded = nullptr);
  33. } // namespace Api
  34. class ConfirmInviteBox final : public Ui::BoxContent {
  35. public:
  36. ConfirmInviteBox(
  37. QWidget*,
  38. not_null<Main::Session*> session,
  39. const MTPDchatInvite &data,
  40. ChannelData *invitePeekChannel,
  41. Fn<void()> submit);
  42. ~ConfirmInviteBox();
  43. protected:
  44. void prepare() override;
  45. void resizeEvent(QResizeEvent *e) override;
  46. void paintEvent(QPaintEvent *e) override;
  47. private:
  48. struct Participant;
  49. struct ChatInvite {
  50. QString title;
  51. QString about;
  52. PhotoData *photo = nullptr;
  53. int participantsCount = 0;
  54. std::vector<Participant> participants;
  55. bool isPublic = false;
  56. bool isChannel = false;
  57. bool isMegagroup = false;
  58. bool isBroadcast = false;
  59. bool isRequestNeeded = false;
  60. bool isFake = false;
  61. bool isScam = false;
  62. bool isVerified = false;
  63. };
  64. [[nodiscard]] static ChatInvite Parse(
  65. not_null<Main::Session*> session,
  66. const MTPDchatInvite &data);
  67. [[nodiscard]] Info::Profile::BadgeType BadgeForInvite(
  68. const ChatInvite &invite);
  69. ConfirmInviteBox(
  70. not_null<Main::Session*> session,
  71. ChatInvite &&invite,
  72. ChannelData *invitePeekChannel,
  73. Fn<void()> submit);
  74. const not_null<Main::Session*> _session;
  75. Fn<void()> _submit;
  76. object_ptr<Ui::FlatLabel> _title;
  77. std::unique_ptr<Info::Profile::Badge> _badge;
  78. object_ptr<Ui::FlatLabel> _status;
  79. object_ptr<Ui::FlatLabel> _about;
  80. object_ptr<Ui::FlatLabel> _aboutRequests;
  81. std::shared_ptr<Data::PhotoMedia> _photo;
  82. std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
  83. std::vector<Participant> _participants;
  84. bool _isChannel = false;
  85. bool _requestApprove = false;
  86. int _userWidth = 0;
  87. };