toPresence method

Presence toPresence()

Implementation

Presence toPresence() {
  final content = <String, dynamic>{
    'presence': presence.toString(),
  };
  if (currentlyActive != null) content['currently_active'] = currentlyActive!;
  if (lastActiveTimestamp != null) {
    content['last_active_ago'] =
        DateTime.now().difference(lastActiveTimestamp!).inMilliseconds;
  }
  if (statusMsg != null) content['status_msg'] = statusMsg!;

  final json = {
    'content': content,
    'sender': '@example:localhost',
    'type': 'm.presence'
  };

  return Presence.fromJson(json);
}