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

Function writePeer

Telegram/SourceFiles/storage/serialize_peer.cpp:156–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
157 stream
158 << SerializePeerId(peer->id)
159 << quint64(kVersionTag)
160 << qint32(kVersion)
161 << quint64(peer->userpicPhotoId());
162 writeImageLocation(stream, peer->userpicLocation());
163 stream << qint32(peer->userpicHasVideo() ? 1 : 0);
164 if (const auto user = peer->asUser()) {
165 const auto botInlinePlaceholder = user->isBot()
166 ? user->botInfo->inlinePlaceholder
167 : QString();
168 stream
169 << user->firstName
170 << user->lastName
171 << user->phone()
172 << user->username()
173 << quint64(user->accessHash())
174 << qint32(user->flags())
175 << botInlinePlaceholder
176 << quint32(user->lastseen().serialize())
177 << qint32(user->isContact() ? 1 : 0)
178 << qint32(user->isBot() ? user->botInfo->version : -1)
179 << qint32(user->isBot()
180 && user->botInfo
181 && user->botInfo->supportsGuestChat);
182 } else if (const auto chat = peer->asChat()) {
183 auto field1 = qint32(uint32(chat->creator.bare & 0xFFFFFFFFULL));
184 auto field2 = qint32(uint32(chat->creator.bare >> 32) << 8);
185 stream
186 << chat->name()
187 << qint32(chat->count)
188 << qint32(chat->date)
189 << qint32(chat->version())
190 << field1
191 << field2
192 << quint32(chat->flags())
193 << chat->inviteLink();
194 } else if (const auto channel = peer->asChannel()) {
195 stream
196 << channel->name()
197 << quint64(channel->accessHash())
198 << qint32(channel->date)
199 << qint32(0) // legacy - version
200 << qint32(0)
201 << quint32(channel->flags())
202 << channel->inviteLink();
203 }
204}
205
206PeerData *readPeer(
207 not_null<Main::Session*> session,

Callers 4

serializeMethod · 0.85
serializeMethod · 0.85
writeMapMethod · 0.85

Calls 15

SerializePeerIdFunction · 0.85
writeImageLocationFunction · 0.85
userpicPhotoIdMethod · 0.80
userpicLocationMethod · 0.80
userpicHasVideoMethod · 0.80
asUserMethod · 0.80
lastseenMethod · 0.80
isContactMethod · 0.80
asChatMethod · 0.80
asChannelMethod · 0.80
QStringClass · 0.50
isBotMethod · 0.45

Tested by

no test coverage detected