feat: view the user's app version on the user page (#21345)

Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
aviv926
2025-10-22 01:36:18 +03:00
committed by GitHub
parent c3a533ab40
commit 032de9ff2f
27 changed files with 301 additions and 50 deletions

View File

@@ -282,6 +282,7 @@ Class | Method | HTTP request | Description
*UsersAdminApi* | [**deleteUserAdmin**](doc//UsersAdminApi.md#deleteuseradmin) | **DELETE** /admin/users/{id} |
*UsersAdminApi* | [**getUserAdmin**](doc//UsersAdminApi.md#getuseradmin) | **GET** /admin/users/{id} |
*UsersAdminApi* | [**getUserPreferencesAdmin**](doc//UsersAdminApi.md#getuserpreferencesadmin) | **GET** /admin/users/{id}/preferences |
*UsersAdminApi* | [**getUserSessionsAdmin**](doc//UsersAdminApi.md#getusersessionsadmin) | **GET** /admin/users/{id}/sessions |
*UsersAdminApi* | [**getUserStatisticsAdmin**](doc//UsersAdminApi.md#getuserstatisticsadmin) | **GET** /admin/users/{id}/statistics |
*UsersAdminApi* | [**restoreUserAdmin**](doc//UsersAdminApi.md#restoreuseradmin) | **POST** /admin/users/{id}/restore |
*UsersAdminApi* | [**searchUsersAdmin**](doc//UsersAdminApi.md#searchusersadmin) | **GET** /admin/users |

View File

@@ -231,6 +231,62 @@ class UsersAdminApi {
return null;
}
/// This endpoint is an admin-only route, and requires the `adminSession.read` permission.
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters:
///
/// * [String] id (required):
Future<Response> getUserSessionsAdminWithHttpInfo(String id,) async {
// ignore: prefer_const_declarations
final apiPath = r'/admin/users/{id}/sessions'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
apiPath,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// This endpoint is an admin-only route, and requires the `adminSession.read` permission.
///
/// Parameters:
///
/// * [String] id (required):
Future<List<SessionResponseDto>?> getUserSessionsAdmin(String id,) async {
final response = await getUserSessionsAdminWithHttpInfo(id,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<SessionResponseDto>') as List)
.cast<SessionResponseDto>()
.toList(growable: false);
}
return null;
}
/// This endpoint is an admin-only route, and requires the `adminUser.read` permission.
///
/// Note: This method returns the HTTP [Response].

View File

@@ -150,6 +150,7 @@ class Permission {
static const adminUserPeriodRead = Permission._(r'adminUser.read');
static const adminUserPeriodUpdate = Permission._(r'adminUser.update');
static const adminUserPeriodDelete = Permission._(r'adminUser.delete');
static const adminSessionPeriodRead = Permission._(r'adminSession.read');
static const adminAuthPeriodUnlinkAll = Permission._(r'adminAuth.unlinkAll');
/// List of all possible values in this [enum][Permission].
@@ -281,6 +282,7 @@ class Permission {
adminUserPeriodRead,
adminUserPeriodUpdate,
adminUserPeriodDelete,
adminSessionPeriodRead,
adminAuthPeriodUnlinkAll,
];
@@ -447,6 +449,7 @@ class PermissionTypeTransformer {
case r'adminUser.read': return Permission.adminUserPeriodRead;
case r'adminUser.update': return Permission.adminUserPeriodUpdate;
case r'adminUser.delete': return Permission.adminUserPeriodDelete;
case r'adminSession.read': return Permission.adminSessionPeriodRead;
case r'adminAuth.unlinkAll': return Permission.adminAuthPeriodUnlinkAll;
default:
if (!allowNull) {

View File

@@ -13,6 +13,7 @@ part of openapi.api;
class SessionCreateResponseDto {
/// Returns a new [SessionCreateResponseDto] instance.
SessionCreateResponseDto({
required this.appVersion,
required this.createdAt,
required this.current,
required this.deviceOS,
@@ -24,6 +25,8 @@ class SessionCreateResponseDto {
required this.updatedAt,
});
String? appVersion;
String createdAt;
bool current;
@@ -50,6 +53,7 @@ class SessionCreateResponseDto {
@override
bool operator ==(Object other) => identical(this, other) || other is SessionCreateResponseDto &&
other.appVersion == appVersion &&
other.createdAt == createdAt &&
other.current == current &&
other.deviceOS == deviceOS &&
@@ -63,6 +67,7 @@ class SessionCreateResponseDto {
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(appVersion == null ? 0 : appVersion!.hashCode) +
(createdAt.hashCode) +
(current.hashCode) +
(deviceOS.hashCode) +
@@ -74,10 +79,15 @@ class SessionCreateResponseDto {
(updatedAt.hashCode);
@override
String toString() => 'SessionCreateResponseDto[createdAt=$createdAt, current=$current, deviceOS=$deviceOS, deviceType=$deviceType, expiresAt=$expiresAt, id=$id, isPendingSyncReset=$isPendingSyncReset, token=$token, updatedAt=$updatedAt]';
String toString() => 'SessionCreateResponseDto[appVersion=$appVersion, createdAt=$createdAt, current=$current, deviceOS=$deviceOS, deviceType=$deviceType, expiresAt=$expiresAt, id=$id, isPendingSyncReset=$isPendingSyncReset, token=$token, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.appVersion != null) {
json[r'appVersion'] = this.appVersion;
} else {
// json[r'appVersion'] = null;
}
json[r'createdAt'] = this.createdAt;
json[r'current'] = this.current;
json[r'deviceOS'] = this.deviceOS;
@@ -103,6 +113,7 @@ class SessionCreateResponseDto {
final json = value.cast<String, dynamic>();
return SessionCreateResponseDto(
appVersion: mapValueOfType<String>(json, r'appVersion'),
createdAt: mapValueOfType<String>(json, r'createdAt')!,
current: mapValueOfType<bool>(json, r'current')!,
deviceOS: mapValueOfType<String>(json, r'deviceOS')!,
@@ -159,6 +170,7 @@ class SessionCreateResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'appVersion',
'createdAt',
'current',
'deviceOS',

View File

@@ -13,6 +13,7 @@ part of openapi.api;
class SessionResponseDto {
/// Returns a new [SessionResponseDto] instance.
SessionResponseDto({
required this.appVersion,
required this.createdAt,
required this.current,
required this.deviceOS,
@@ -23,6 +24,8 @@ class SessionResponseDto {
required this.updatedAt,
});
String? appVersion;
String createdAt;
bool current;
@@ -47,6 +50,7 @@ class SessionResponseDto {
@override
bool operator ==(Object other) => identical(this, other) || other is SessionResponseDto &&
other.appVersion == appVersion &&
other.createdAt == createdAt &&
other.current == current &&
other.deviceOS == deviceOS &&
@@ -59,6 +63,7 @@ class SessionResponseDto {
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(appVersion == null ? 0 : appVersion!.hashCode) +
(createdAt.hashCode) +
(current.hashCode) +
(deviceOS.hashCode) +
@@ -69,10 +74,15 @@ class SessionResponseDto {
(updatedAt.hashCode);
@override
String toString() => 'SessionResponseDto[createdAt=$createdAt, current=$current, deviceOS=$deviceOS, deviceType=$deviceType, expiresAt=$expiresAt, id=$id, isPendingSyncReset=$isPendingSyncReset, updatedAt=$updatedAt]';
String toString() => 'SessionResponseDto[appVersion=$appVersion, createdAt=$createdAt, current=$current, deviceOS=$deviceOS, deviceType=$deviceType, expiresAt=$expiresAt, id=$id, isPendingSyncReset=$isPendingSyncReset, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.appVersion != null) {
json[r'appVersion'] = this.appVersion;
} else {
// json[r'appVersion'] = null;
}
json[r'createdAt'] = this.createdAt;
json[r'current'] = this.current;
json[r'deviceOS'] = this.deviceOS;
@@ -97,6 +107,7 @@ class SessionResponseDto {
final json = value.cast<String, dynamic>();
return SessionResponseDto(
appVersion: mapValueOfType<String>(json, r'appVersion'),
createdAt: mapValueOfType<String>(json, r'createdAt')!,
current: mapValueOfType<bool>(json, r'current')!,
deviceOS: mapValueOfType<String>(json, r'deviceOS')!,
@@ -152,6 +163,7 @@ class SessionResponseDto {
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'appVersion',
'createdAt',
'current',
'deviceOS',