Skip to content

Commit 6005a75

Browse files
committed
Merge branch 'dev' of https://github.com/telegramdesktop/tdesktop into upstream
2 parents 7b671a9 + 88ad1be commit 6005a75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+727
-172
lines changed

.github/workflows/docker.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: Clone.
23-
uses: actions/checkout@v4.1.4
23+
uses: actions/checkout@v4
2424
with:
2525
submodules: recursive
2626

@@ -31,7 +31,7 @@ jobs:
3131
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
3232
3333
- name: Free up some disk space.
34-
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
34+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
3535

3636
- name: Docker image build.
3737
run: |

.github/workflows/linux.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
6060

6161
- name: Clone.
62-
uses: actions/checkout@v4.1.4
62+
uses: actions/checkout@v4
6363
with:
6464
submodules: recursive
6565
path: ${{ env.REPO_NAME }}
@@ -117,7 +117,7 @@ jobs:
117117
cd $REPO_NAME/out/Debug
118118
sudo mkdir artifact
119119
sudo mv {Telegram,Updater} artifact/
120-
- uses: actions/upload-artifact@master
120+
- uses: actions/upload-artifact@v2
121121
if: env.UPLOAD_ARTIFACT == 'true'
122122
name: Upload artifact.
123123
with:

.github/workflows/mac.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
5858

5959
- name: Clone.
60-
uses: actions/checkout@v4.1.4
60+
uses: actions/checkout@v4
6161
with:
6262
submodules: recursive
6363
path: ${{ env.REPO_NAME }}
@@ -77,15 +77,15 @@ jobs:
7777
7878
- name: ThirdParty cache.
7979
id: cache-third-party
80-
uses: actions/cache@v4.0.2
80+
uses: actions/cache@v4
8181
with:
8282
path: ThirdParty
8383
key: ${{ runner.OS }}-third-party-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }}
8484
restore-keys: ${{ runner.OS }}-third-party-
8585

8686
- name: Libraries cache.
8787
id: cache-libs
88-
uses: actions/cache@v4.0.2
88+
uses: actions/cache@v4
8989
with:
9090
path: Libraries
9191
key: ${{ runner.OS }}-libs-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }}
@@ -134,7 +134,8 @@ jobs:
134134
cd $REPO_NAME/out/Debug
135135
mkdir artifact
136136
mv rabbitGram.app artifact/
137-
- uses: actions/upload-artifact@master
137+
mv Updater artifact/
138+
- uses: actions/upload-artifact@v2
138139
if: env.UPLOAD_ARTIFACT == 'true'
139140
name: Upload artifact.
140141
with:

.github/workflows/mac_packaged.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
6161

6262
- name: Clone.
63-
uses: actions/checkout@v4.1.4
63+
uses: actions/checkout@v4
6464
with:
6565
submodules: recursive
6666
path: ${{ env.REPO_NAME }}
@@ -99,7 +99,7 @@ jobs:
9999
100100
- name: WebRTC cache.
101101
id: cache-webrtc
102-
uses: actions/cache@v4.0.2
102+
uses: actions/cache@v4
103103
with:
104104
path: ${{ env.LibrariesPath }}/tg_owt
105105
key: ${{ runner.OS }}-webrtc-${{ env.CACHE_KEY }}-${{ hashFiles('**/tg_owt-version.json') }}
@@ -153,7 +153,7 @@ jobs:
153153
cd $REPO_NAME/build
154154
mkdir artifact
155155
mv Telegram.dmg artifact/
156-
- uses: actions/upload-artifact@master
156+
- uses: actions/upload-artifact@v2
157157
if: env.UPLOAD_ARTIFACT == 'true'
158158
name: Upload artifact.
159159
with:

.github/workflows/master_updater.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
SKIP: "0"
1212
to_branch: "master"
1313
steps:
14-
- uses: actions/checkout@v4.1.4
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717
if: env.SKIP == '0'

.github/workflows/snap.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
steps:
5050
- name: Clone.
51-
uses: actions/checkout@v4.1.4
51+
uses: actions/checkout@v4
5252
with:
5353
fetch-depth: 0
5454
submodules: recursive
@@ -62,7 +62,7 @@ jobs:
6262
sudo snap run lxd waitready
6363
6464
- name: Free up some disk space.
65-
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
65+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
6666

6767
- name: Telegram Desktop snap build.
6868
run: sg lxd -c 'snap run snapcraft --verbosity=debug'
@@ -76,7 +76,7 @@ jobs:
7676
mkdir artifact
7777
mv $artifact_name artifact
7878
79-
- uses: actions/upload-artifact@master
79+
- uses: actions/upload-artifact@v2
8080
if: env.UPLOAD_ARTIFACT == 'true'
8181
name: Upload artifact.
8282
with:

.github/workflows/win.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
arch: ${{ matrix.arch }}
8080

8181
- name: Clone.
82-
uses: actions/checkout@v4.1.4
82+
uses: actions/checkout@v4
8383
with:
8484
submodules: recursive
8585
path: ${{ env.TBUILD }}\${{ env.REPO_NAME }}
@@ -100,7 +100,7 @@ jobs:
100100
101101
- name: Libraries cache.
102102
id: cache-libs
103-
uses: actions/cache@v4.0.2
103+
uses: actions/cache@v4
104104
with:
105105
path: ${{ env.TBUILD }}\Libraries
106106
key: ${{ runner.OS }}-${{ matrix.arch }}-libs-${{ env.CACHE_KEY }}
@@ -180,7 +180,8 @@ jobs:
180180
set OUT=%TBUILD%\%REPO_NAME%\out\Debug
181181
mkdir artifact
182182
move %OUT%\rabbitGram.exe artifact/
183-
- uses: actions/upload-artifact@master
183+
move %OUT%\Updater.exe artifact/
184+
- uses: actions/upload-artifact@v2
184185
name: Upload artifact.
185186
if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly')
186187
with:

Telegram/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ PRIVATE
688688
history/view/controls/compose_controls_common.h
689689
history/view/controls/history_view_compose_controls.cpp
690690
history/view/controls/history_view_compose_controls.h
691+
history/view/controls/history_view_compose_media_edit_manager.cpp
692+
history/view/controls/history_view_compose_media_edit_manager.h
691693
history/view/controls/history_view_compose_search.cpp
692694
history/view/controls/history_view_compose_search.h
693695
history/view/controls/history_view_draft_options.cpp

Telegram/SourceFiles/api/api_editing.cpp

+91-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ For license and copyright information please follow this link:
1313
#include "ui/boxes/confirm_box.h"
1414
#include "data/business/data_shortcut_messages.h"
1515
#include "data/components/scheduled_messages.h"
16+
#include "data/data_file_origin.h"
1617
#include "data/data_histories.h"
1718
#include "data/data_session.h"
1819
#include "data/data_web_page.h"
@@ -252,12 +253,100 @@ mtpRequestId EditTextMessage(
252253
Data::WebPageDraft webpage,
253254
SendOptions options,
254255
Fn<void(mtpRequestId requestId)> done,
255-
Fn<void(const QString &, mtpRequestId requestId)> fail) {
256+
Fn<void(const QString &error, mtpRequestId requestId)> fail,
257+
std::optional<bool> spoilerMediaOverride) {
258+
if (spoilerMediaOverride) {
259+
const auto spoiler = *spoilerMediaOverride;
260+
if (const auto media = item->media()) {
261+
auto takeInputMedia = Fn<std::optional<MTPInputMedia>()>(nullptr);
262+
auto takeFileReference = Fn<QByteArray()>(nullptr);
263+
if (const auto photo = media->photo()) {
264+
using Flag = MTPDinputMediaPhoto::Flag;
265+
const auto flags = Flag()
266+
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
267+
| (spoiler ? Flag::f_spoiler : Flag());
268+
takeInputMedia = [=] {
269+
return MTP_inputMediaPhoto(
270+
MTP_flags(flags),
271+
photo->mtpInput(),
272+
MTP_int(media->ttlSeconds()));
273+
};
274+
takeFileReference = [=] { return photo->fileReference(); };
275+
} else if (const auto document = media->document()) {
276+
using Flag = MTPDinputMediaDocument::Flag;
277+
const auto flags = Flag()
278+
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
279+
| (spoiler ? Flag::f_spoiler : Flag());
280+
takeInputMedia = [=] {
281+
return MTP_inputMediaDocument(
282+
MTP_flags(flags),
283+
document->mtpInput(),
284+
MTP_int(media->ttlSeconds()),
285+
MTPstring()); // query
286+
};
287+
takeFileReference = [=] { return document->fileReference(); };
288+
}
289+
290+
const auto usedFileReference = takeFileReference
291+
? takeFileReference()
292+
: QByteArray();
293+
const auto origin = item->fullId();
294+
const auto api = &item->history()->session().api();
295+
const auto performRequest = [=](
296+
const auto &repeatRequest,
297+
mtpRequestId originalRequestId) -> mtpRequestId {
298+
const auto handleReference = [=](
299+
const QString &error,
300+
mtpRequestId requestId) {
301+
if (error.startsWith(u"FILE_REFERENCE_"_q)) {
302+
api->refreshFileReference(origin, [=](const auto &) {
303+
if (takeFileReference &&
304+
(takeFileReference() != usedFileReference)) {
305+
repeatRequest(
306+
repeatRequest,
307+
originalRequestId
308+
? originalRequestId
309+
: requestId);
310+
} else {
311+
fail(error, requestId);
312+
}
313+
});
314+
} else {
315+
fail(error, requestId);
316+
}
317+
};
318+
const auto callback = [=](
319+
Fn<void()> applyUpdates,
320+
mtpRequestId requestId) {
321+
applyUpdates();
322+
done(originalRequestId ? originalRequestId : requestId);
323+
};
324+
const auto requestId = EditMessage(
325+
item,
326+
caption,
327+
webpage,
328+
options,
329+
callback,
330+
handleReference,
331+
takeInputMedia ? takeInputMedia() : std::nullopt);
332+
return originalRequestId ? originalRequestId : requestId;
333+
};
334+
return performRequest(performRequest, 0);
335+
}
336+
}
337+
256338
const auto callback = [=](Fn<void()> applyUpdates, mtpRequestId id) {
257339
applyUpdates();
258340
done(id);
259341
};
260-
return EditMessage(item, caption, webpage, options, callback, fail);
342+
return EditMessage(
343+
item,
344+
caption,
345+
webpage,
346+
options,
347+
callback,
348+
fail,
349+
std::nullopt);
261350
}
262351

263352
} // namespace Api

Telegram/SourceFiles/api/api_editing.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mtpRequestId EditTextMessage(
5555
Data::WebPageDraft webpage,
5656
SendOptions options,
5757
Fn<void(mtpRequestId requestId)> done,
58-
Fn<void(const QString &error, mtpRequestId requestId)> fail);
58+
Fn<void(const QString &error, mtpRequestId requestId)> fail,
59+
std::optional<bool> spoilerMediaOverride);
5960

6061
} // namespace Api

0 commit comments

Comments
 (0)