MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / updateSelf

Method updateSelf

Telegram/SourceFiles/api/api_peer_photo.cpp:198–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void PeerPhoto::updateSelf(
199 not_null<PhotoData*> photo,
200 Data::FileOrigin origin,
201 Fn<void()> done) {
202 const auto send = [=](auto resend) -> void {
203 const auto usedFileReference = photo->fileReference();
204 _api.request(MTPphotos_UpdateProfilePhoto(
205 MTP_flags(0),
206 MTPInputUser(), // bot
207 photo->mtpInput()
208 )).done([=](const MTPphotos_Photo &result) {
209 result.match([&](const MTPDphotos_photo &data) {
210 _session->data().processPhoto(data.vphoto());
211 _session->data().processUsers(data.vusers());
212 });
213 if (done) {
214 done();
215 }
216 }).fail([=](const MTP::Error &error) {
217 if (error.code() == 400
218 && error.type().startsWith(u"FILE_REFERENCE_"_q)) {
219 photo->session().api().refreshFileReference(origin, [=](
220 const auto &) {
221 if (photo->fileReference() != usedFileReference) {
222 resend(resend);
223 }
224 });
225 }
226 }).send();
227 };
228 send(send);
229}
230
231void PeerPhoto::upload(
232 not_null<PeerData*> peer,

Callers 1

ShowUserpicSuggestionFunction · 0.80

Calls 15

MTP_flagsFunction · 0.85
sendFunction · 0.85
processUsersMethod · 0.80
apiMethod · 0.80
fileReferenceMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45
mtpInputMethod · 0.45
processPhotoMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected