api_polls.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. class HistoryItem;
  11. struct PollData;
  12. namespace Main {
  13. class Session;
  14. } // namespace Main
  15. namespace Api {
  16. struct SendAction;
  17. class Polls final {
  18. public:
  19. explicit Polls(not_null<ApiWrap*> api);
  20. void create(
  21. const PollData &data,
  22. SendAction action,
  23. Fn<void()> done,
  24. Fn<void()> fail);
  25. void sendVotes(
  26. FullMsgId itemId,
  27. const std::vector<QByteArray> &options);
  28. void close(not_null<HistoryItem*> item);
  29. void reloadResults(not_null<HistoryItem*> item);
  30. private:
  31. const not_null<Main::Session*> _session;
  32. MTP::Sender _api;
  33. base::flat_map<FullMsgId, mtpRequestId> _pollVotesRequestIds;
  34. base::flat_map<FullMsgId, mtpRequestId> _pollCloseRequestIds;
  35. base::flat_map<FullMsgId, mtpRequestId> _pollReloadRequestIds;
  36. };
  37. } // namespace Api