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

Method clear

Telegram/SourceFiles/api/api_peer_photo.cpp:331–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331void PeerPhoto::clear(not_null<PhotoData*> photo) {
332 const auto self = _session->user();
333 if (self->userpicPhotoId() == photo->id) {
334 const auto photoId = photo->id;
335 const auto peerId = self->id;
336 _api.request(MTPphotos_UpdateProfilePhoto(
337 MTP_flags(0),
338 MTPInputUser(), // bot
339 MTP_inputPhotoEmpty()
340 )).done([=](const MTPphotos_Photo &result) {
341 self->setPhoto(MTP_userProfilePhotoEmpty());
342 _session->storage().remove(
343 Storage::UserPhotosRemoveOne(peerToUser(peerId), photoId));
344 }).send();
345 } else if (photo->peer && photo->peer->userpicPhotoId() == photo->id) {
346 const auto applier = [=](const MTPUpdates &result) {
347 _session->updates().applyUpdates(result);
348 };
349 if (const auto chat = photo->peer->asChat()) {
350 _api.request(MTPmessages_EditChatPhoto(
351 chat->inputChat(),
352 MTP_inputChatPhotoEmpty()
353 )).done(applier).send();
354 } else if (const auto channel = photo->peer->asChannel()) {
355 _api.request(MTPchannels_EditPhoto(
356 channel->inputChannel(),
357 MTP_inputChatPhotoEmpty()
358 )).done(applier).send();
359 }
360 } else {
361 const auto fallbackPhotoId = SyncUserFallbackPhotoViewer(self);
362 if (fallbackPhotoId && (*fallbackPhotoId) == photo->id) {
363 _api.request(MTPphotos_UpdateProfilePhoto(
364 MTP_flags(MTPphotos_UpdateProfilePhoto::Flag::f_fallback),
365 MTPInputUser(), // bot
366 MTP_inputPhotoEmpty()
367 )).send();
368 _session->storage().add(Storage::UserPhotosSetBack(
369 peerToUser(self->id),
370 PhotoId()));
371 } else {
372 _api.request(MTPphotos_DeletePhotos(
373 MTP_vector<MTPInputPhoto>(1, photo->mtpInput())
374 )).send();
375 _session->storage().remove(Storage::UserPhotosRemoveOne(
376 peerToUser(self->id),
377 photo->id));
378 }
379 }
380}
381
382void PeerPhoto::clearPersonal(not_null<UserData*> user) {
383 _api.request(MTPphotos_UploadContactProfilePhoto(

Callers 15

requestTerminateMethod · 0.45
ApplyLastListFunction · 0.45
ApplyBotsListFunction · 0.45
requestBotsMethod · 0.45
addMethod · 0.45
getDifferenceMethod · 0.45
requestListMethod · 0.45
applyUpdateMethod · 0.45
sendPollRequestsMethod · 0.45
requestTerminateMethod · 0.45
reloadStickersMethod · 0.45
reloadCloudSetMethod · 0.45

Calls 15

MTP_flagsFunction · 0.85
peerToUserFunction · 0.85
userpicPhotoIdMethod · 0.80
asChatMethod · 0.80
inputChatMethod · 0.80
asChannelMethod · 0.80
inputChannelMethod · 0.80
UserPhotosRemoveOneClass · 0.50
UserPhotosSetBackClass · 0.50
userMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected