| 154 | } |
| 155 | |
| 156 | void 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 | |
| 206 | PeerData *readPeer( |
| 207 | not_null<Main::Session*> session, |
no test coverage detected