factchecks.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "base/timer.h"
  9. class HistoryItem;
  10. struct HistoryMessageFactcheck;
  11. namespace HistoryView {
  12. class Message;
  13. class WebPage;
  14. } // namespace HistoryView
  15. namespace Main {
  16. class Session;
  17. } // namespace Main
  18. namespace Ui {
  19. class Show;
  20. } // namespace Ui
  21. namespace Data {
  22. class Factchecks final {
  23. public:
  24. explicit Factchecks(not_null<Main::Session*> session);
  25. void requestFor(not_null<HistoryItem*> item);
  26. [[nodiscard]] std::unique_ptr<HistoryView::WebPage> makeMedia(
  27. not_null<HistoryView::Message*> view,
  28. not_null<HistoryMessageFactcheck*> factcheck);
  29. [[nodiscard]] bool canEdit(not_null<HistoryItem*> item) const;
  30. [[nodiscard]] int lengthLimit() const;
  31. void save(
  32. FullMsgId itemId,
  33. TextWithEntities text,
  34. Fn<void(QString)> done);
  35. void save(
  36. FullMsgId itemId,
  37. const TextWithEntities &was,
  38. TextWithEntities text,
  39. std::shared_ptr<Ui::Show> show);
  40. private:
  41. [[nodiscard]] bool canEdit() const;
  42. void subscribeIfNotYet();
  43. void request();
  44. const not_null<Main::Session*> _session;
  45. base::Timer _requestTimer;
  46. base::flat_set<not_null<HistoryItem*>> _pending;
  47. std::vector<HistoryItem*> _requested;
  48. mtpRequestId _requestId = 0;
  49. bool _subscribed = false;
  50. rpl::lifetime _lifetime;
  51. };
  52. } // namespace Data