mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Wrap messageActionGeoProximityReached service message.
This commit is contained in:
@@ -1093,7 +1093,25 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||
}, [&](const ActionContactSignUp &data) {
|
||||
return serviceFrom + " joined Telegram";
|
||||
}, [&](const ActionGeoProximityReached &data) {
|
||||
return serviceFrom + " reached"; // #TODO files distance from to
|
||||
const auto fromName = peers.wrapPeerName(data.fromId);
|
||||
const auto toName = peers.wrapPeerName(data.toId);
|
||||
const auto distance = [&]() -> QString {
|
||||
if (data.distance >= 1000) {
|
||||
const auto km = (10 * (data.distance / 10)) / 1000.;
|
||||
return QString::number(km) + " km";
|
||||
} else if (data.distance == 1) {
|
||||
return "1 meter";
|
||||
} else {
|
||||
return QString::number(data.distance) + " meters";
|
||||
}
|
||||
}().toUtf8();
|
||||
if (data.fromSelf) {
|
||||
return "You are now within " + distance + " from " + toName;
|
||||
} else if (data.toSelf) {
|
||||
return fromName + " is now within " + distance + " from you";
|
||||
} else {
|
||||
return fromName + " is now within " + distance + " from " + toName;
|
||||
}
|
||||
}, [&](const ActionPhoneNumberRequest &data) {
|
||||
return serviceFrom + " requested your phone number";
|
||||
}, [](v::null_t) { return QByteArray(); });
|
||||
|
@@ -296,7 +296,7 @@ QByteArray SerializeMessage(
|
||||
const auto pushFrom = [&](const QByteArray &label = "from") {
|
||||
if (message.fromId) {
|
||||
pushBare(label, wrapPeerName(message.fromId));
|
||||
push(label+"_id", message.fromId);
|
||||
push(label + "_id", message.fromId);
|
||||
}
|
||||
};
|
||||
const auto pushReplyToMsgId = [&](
|
||||
@@ -474,8 +474,16 @@ QByteArray SerializeMessage(
|
||||
pushActor();
|
||||
pushAction("joined_telegram");
|
||||
}, [&](const ActionGeoProximityReached &data) {
|
||||
pushActor();
|
||||
pushAction("proximity_reached"); // #TODO files distance from to
|
||||
pushAction("proximity_reached");
|
||||
if (data.fromId) {
|
||||
pushBare("from", wrapPeerName(data.fromId));
|
||||
push("from_id", data.fromId);
|
||||
}
|
||||
if (data.toId) {
|
||||
pushBare("to", wrapPeerName(data.toId));
|
||||
push("to_id", data.toId);
|
||||
}
|
||||
push("distance", data.distance);
|
||||
}, [&](const ActionPhoneNumberRequest &data) {
|
||||
pushActor();
|
||||
pushAction("requested_phone_number");
|
||||
|
Reference in New Issue
Block a user