mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added geolocation support to poll answer media data layer.
This commit is contained in:
@@ -374,6 +374,13 @@ MTPInputMedia PollMediaToMTP(const PollMedia &media) {
|
||||
MTP_int(0),
|
||||
MTP_int(0),
|
||||
MTPstring());
|
||||
} else if (media.geo) {
|
||||
return MTP_inputMediaGeoPoint(
|
||||
MTP_inputGeoPoint(
|
||||
MTP_flags(0),
|
||||
MTP_double(media.geo->lat()),
|
||||
MTP_double(media.geo->lon()),
|
||||
MTPint())); // accuracy_radius
|
||||
}
|
||||
return MTPInputMedia();
|
||||
}
|
||||
@@ -396,6 +403,16 @@ PollMedia PollMediaFromMTP(
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
}, [&](const MTPDmessageMediaGeo &data) {
|
||||
data.vgeo().match([&](const MTPDgeoPoint &point) {
|
||||
result.geo = Data::LocationPoint(point);
|
||||
}, [](const MTPDgeoPointEmpty &) {
|
||||
});
|
||||
}, [&](const MTPDmessageMediaVenue &data) {
|
||||
data.vgeo().match([&](const MTPDgeoPoint &point) {
|
||||
result.geo = Data::LocationPoint(point);
|
||||
}, [](const MTPDgeoPointEmpty &) {
|
||||
});
|
||||
}, [](const auto &) {
|
||||
});
|
||||
return result;
|
||||
@@ -415,6 +432,14 @@ PollMedia PollMediaFromInputMTP(
|
||||
result.document = owner->document(document.vid().v);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}, [&](const MTPDinputMediaGeoPoint &data) {
|
||||
data.vgeo_point().match([&](const MTPDinputGeoPoint &point) {
|
||||
result.geo.emplace(
|
||||
point.vlat().v,
|
||||
point.vlong().v,
|
||||
Data::LocationPoint::NoAccessHash);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}, [](const auto &) {
|
||||
});
|
||||
return result;
|
||||
|
||||
@@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_location.h"
|
||||
|
||||
namespace Data {
|
||||
class Session;
|
||||
} // namespace Data
|
||||
@@ -22,12 +24,15 @@ class DocumentData;
|
||||
struct PollMedia {
|
||||
PhotoData *photo = nullptr;
|
||||
DocumentData *document = nullptr;
|
||||
std::optional<Data::LocationPoint> geo;
|
||||
|
||||
explicit operator bool() const { return photo || document; }
|
||||
explicit operator bool() const { return photo || document || geo; }
|
||||
};
|
||||
|
||||
inline bool operator==(const PollMedia &a, const PollMedia &b) {
|
||||
return (a.photo == b.photo) && (a.document == b.document);
|
||||
return (a.photo == b.photo)
|
||||
&& (a.document == b.document)
|
||||
&& (a.geo == b.geo);
|
||||
}
|
||||
|
||||
inline bool operator!=(const PollMedia &a, const PollMedia &b) {
|
||||
|
||||
@@ -4371,6 +4371,16 @@ not_null<PollData*> Session::processPoll(const MTPDmessageMediaPoll &data) {
|
||||
if (document && document->type() == mtpc_document) {
|
||||
media.document = processDocument(*document);
|
||||
}
|
||||
}, [&](const MTPDmessageMediaGeo &data) {
|
||||
data.vgeo().match([&](const MTPDgeoPoint &point) {
|
||||
media.geo = LocationPoint(point);
|
||||
}, [](const MTPDgeoPointEmpty &) {
|
||||
});
|
||||
}, [&](const MTPDmessageMediaVenue &data) {
|
||||
data.vgeo().match([&](const MTPDgeoPoint &point) {
|
||||
media.geo = LocationPoint(point);
|
||||
}, [](const MTPDgeoPointEmpty &) {
|
||||
});
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user