Skip to content
Repos

DevPlaceApp

C++ 670 B20 lines Opens in site

Directory Raw Download

#include "model/MessagesInbox.hpp"

#include "core/JsonDecode.hpp"

namespace dp {

MessagesInbox MessagesInbox::fromJson(const Json& j) {
  using D = JsonDecode;
  MessagesInbox m;
  m.conversations = D::reqModels<Conversation>(j, "conversations");
  m.messages = D::reqModels<Message>(j, "messages");
  if (const Json* other = JsonRead::child(j, "other_user")) m.otherUser = User::fromJson(*other);
  m.currentConversation = D::opt<std::string>(j, "current_conversation");
  m.search = D::req<std::string>(j, "search");
  m.otherOnline = D::req<bool>(j, "other_online");
  m.otherLastSeen = D::opt<std::string>(j, "other_last_seen");
  return m;
}

}  // namespace dp
35.8ms