Skip to content

Commit

Permalink
add displayname and avatarurl to presence response
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed Jun 24, 2024
1 parent 00b6570 commit b46486a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
15 changes: 14 additions & 1 deletion lib/src/generated/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,8 @@ class GetPresenceResponse {
this.lastActiveAgo,
required this.presence,
this.statusMsg,
this.avatarUrl,
this.displayname,
});

GetPresenceResponse.fromJson(Map<String, Object?> json)
Expand All @@ -1587,7 +1589,10 @@ class GetPresenceResponse {
lastActiveAgo =
((v) => v != null ? v as int : null)(json['last_active_ago']),
presence = PresenceType.values.fromString(json['presence'] as String)!,
statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']);
statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']),
avatarUrl = ((v) => v != null ? v as String : null)(json['avatar_url']),
displayname =
((v) => v != null ? v as String : null)(json['displayname']);
Map<String, Object?> toJson() {
final currentlyActive = this.currentlyActive;
final lastActiveAgo = this.lastActiveAgo;
Expand All @@ -1597,6 +1602,8 @@ class GetPresenceResponse {
if (lastActiveAgo != null) 'last_active_ago': lastActiveAgo,
'presence': presence.name,
if (statusMsg != null) 'status_msg': statusMsg,
if (avatarUrl != null) 'avatar_url': avatarUrl,
if (displayname != null) 'displayname': displayname,
};
}

Expand All @@ -1612,6 +1619,12 @@ class GetPresenceResponse {

/// The state message for this user if one was set.
String? statusMsg;

/// The avatarUrl of current user if have
String? avatarUrl;

/// The displayname of current user if have
String? displayname;
}

///
Expand Down
16 changes: 13 additions & 3 deletions lib/src/model/presence_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ class PresenceContent {
int? lastActiveAgo;
String? statusMsg;
bool? currentlyActive;
String? avatarUrl;
String? displayname;

PresenceContent.fromJson(Map<String, Object?> json)
: presence = PresenceType.values.firstWhere(
(p) => p.toString().split('.').last == json['presence']),
: presence =
PresenceType.values.firstWhere((p) => p.toString().split('.').last == json['presence']),
lastActiveAgo = json.tryGet<int>('last_active_ago'),
statusMsg = json.tryGet<String>('status_msg'),
currentlyActive = json.tryGet<bool>('currently_active');
currentlyActive = json.tryGet<bool>('currently_active'),
avatarUrl = json.tryGet<String>('avatar_url'),
displayname = json.tryGet<String>('displayname');

Map<String, Object?> toJson() {
final data = <String, Object?>{};
Expand All @@ -48,6 +52,12 @@ class PresenceContent {
if (currentlyActive != null) {
data['currently_active'] = currentlyActive;
}
if (avatarUrl != null) {
data['avatar_url'] = avatarUrl;
}
if (displayname != null) {
data['displayname'] = displayname;
}
return data;
}
}

0 comments on commit b46486a

Please sign in to comment.