export_settings.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "export/export_settings.h"
  8. #include "export/output/export_output_abstract.h"
  9. namespace Export {
  10. namespace {
  11. constexpr auto kMaxFileSize = 4000 * int64(1024 * 1024);
  12. } // namespace
  13. bool MediaSettings::validate() const {
  14. if ((types | Type::AllMask) != Type::AllMask) {
  15. return false;
  16. } else if (sizeLimit < 0 || sizeLimit > kMaxFileSize) {
  17. return false;
  18. }
  19. return true;
  20. }
  21. bool Settings::validate() const {
  22. using Format = Output::Format;
  23. const auto MustBeFull = Type::PersonalChats | Type::BotChats;
  24. const auto MustNotBeFull = Type::PublicGroups | Type::PublicChannels;
  25. if ((types | Type::AllMask) != Type::AllMask) {
  26. return false;
  27. } else if ((fullChats | Type::AllMask) != Type::AllMask) {
  28. return false;
  29. } else if ((fullChats & MustBeFull) != MustBeFull) {
  30. return false;
  31. } else if ((fullChats & MustNotBeFull) != 0) {
  32. return false;
  33. } else if (format != Format::Html && format != Format::Json) {
  34. return false;
  35. } else if (!media.validate()) {
  36. return false;
  37. } else if (singlePeerTill > 0 && singlePeerTill <= singlePeerFrom) {
  38. return false;
  39. }
  40. return true;
  41. };
  42. } // namespace Export