Generate and handle new video message links.

This commit is contained in:
John Preston 2017-04-30 16:31:11 +03:00
parent cd6a189990
commit a925822141
3 changed files with 17 additions and 5 deletions

View File

@ -40,7 +40,7 @@ QString tryConvertUrlToLocal(QString url) {
using namespace qthelp;
auto matchOptions = RegExOption::CaseInsensitive;
auto telegramMeMatch = regex_match(qsl("^https?://(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions);
auto telegramMeMatch = regex_match(qsl("^https?://(www\\.)?(telegram\\.(me|dog)|t\\.me|telesco\\.pe)/(.+)$"), url, matchOptions);
if (telegramMeMatch) {
auto query = telegramMeMatch->capturedRef(4);
if (auto joinChatMatch = regex_match(qsl("^joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {

View File

@ -796,8 +796,20 @@ bool HistoryItem::canDeleteForEveryone(const QDateTime &cur) const {
}
QString HistoryItem::directLink() const {
return hasDirectLink() ? Messenger::Instance().createInternalLinkFull(_history->peer->asChannel()->username + '/' + QString::number(id)) : QString();
if (hasDirectLink()) {
auto query = _history->peer->asChannel()->username + '/' + QString::number(id);
if (auto media = getMedia()) {
if (auto document = media->getDocument()) {
if (document->isRoundVideo()) {
return qsl("https://telesco.pe/") + query;
}
}
}
return Messenger::Instance().createInternalLinkFull(query);
}
return QString();
}
bool HistoryItem::unread() const {
// Messages from myself are always read.
if (history()->peer->isSelf()) return false;

View File

@ -5422,10 +5422,10 @@ void HistoryWidget::onPinnedHide() {
}
void HistoryWidget::onCopyPostLink() {
HistoryItem *to = App::contextItem();
if (!to || !to->hasDirectLink()) return;
auto item = App::contextItem();
if (!item || !item->hasDirectLink()) return;
QApplication::clipboard()->setText(to->directLink());
QApplication::clipboard()->setText(item->directLink());
}
bool HistoryWidget::lastForceReplyReplied(const FullMsgId &replyTo) const {