api_websites.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "mtproto/sender.h"
  9. class ApiWrap;
  10. namespace Main {
  11. class Session;
  12. } // namespace Main
  13. namespace Api {
  14. class Websites final {
  15. public:
  16. explicit Websites(not_null<ApiWrap*> api);
  17. struct Entry {
  18. uint64 hash = 0;
  19. not_null<UserData*> bot;
  20. TimeId activeTime = 0;
  21. QString active, platform, domain, browser, ip, location;
  22. };
  23. using List = std::vector<Entry>;
  24. void reload();
  25. void cancelCurrentRequest();
  26. void requestTerminate(
  27. Fn<void(const MTPBool &result)> &&done,
  28. Fn<void(const MTP::Error &error)> &&fail,
  29. std::optional<uint64> hash = std::nullopt,
  30. UserData *botToBlock = nullptr);
  31. [[nodiscard]] crl::time lastReceivedTime();
  32. [[nodiscard]] List list() const;
  33. [[nodiscard]] rpl::producer<List> listValue() const;
  34. [[nodiscard]] int total() const;
  35. [[nodiscard]] rpl::producer<int> totalValue() const;
  36. private:
  37. not_null<Main::Session*> _session;
  38. MTP::Sender _api;
  39. mtpRequestId _requestId = 0;
  40. List _list;
  41. rpl::event_stream<> _listChanges;
  42. crl::time _lastReceived = 0;
  43. rpl::lifetime _lifetime;
  44. };
  45. } // namespace Api