Merge pull request #884 from GetStream/release/3.4.0
chore(llc,core,ui,persistence,localizations): 3.4.0
This commit is contained in:
@@ -96,4 +96,16 @@ class GeneralApi {
|
||||
|
||||
return QueryMembersResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
/// Get OpenGraph data of the given [url].
|
||||
Future<OGAttachmentResponse> enrichUrl(String url) async {
|
||||
final response = await _client.get(
|
||||
'/og',
|
||||
queryParameters: {
|
||||
'url': url,
|
||||
},
|
||||
);
|
||||
|
||||
return OGAttachmentResponse.fromJson(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:stream_chat/src/core/api/responses.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:stream_chat/src/core/http/stream_http_client.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
/// Defines the api dedicated to moderation operations
|
||||
class ModerationApi {
|
||||
@@ -125,4 +127,24 @@ class ModerationApi {
|
||||
);
|
||||
return EmptyResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
/// Queries banned users.
|
||||
Future<QueryBannedUsersResponse> queryBannedUsers({
|
||||
Filter? filter,
|
||||
List<SortOption>? sort,
|
||||
PaginationParams? pagination,
|
||||
}) async {
|
||||
final response = await _client.get(
|
||||
'/query_banned_users',
|
||||
queryParameters: {
|
||||
'payload': jsonEncode({
|
||||
if (sort != null) 'sort': sort,
|
||||
if (filter != null) 'filter_conditions': filter,
|
||||
if (pagination != null) ...pagination.toJson(),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
return QueryBannedUsersResponse.fromJson(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/client/client.dart';
|
||||
import 'package:stream_chat/src/core/error/error.dart';
|
||||
import 'package:stream_chat/src/core/models/banned_user.dart';
|
||||
import 'package:stream_chat/src/core/models/channel_model.dart';
|
||||
import 'package:stream_chat/src/core/models/channel_state.dart';
|
||||
import 'package:stream_chat/src/core/models/device.dart';
|
||||
@@ -106,6 +107,18 @@ class QueryUsersResponse extends _BaseResponse {
|
||||
_$QueryUsersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [StreamChatClient.queryBannedUsers] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryBannedUsersResponse extends _BaseResponse {
|
||||
/// List of users returned by the query
|
||||
@JsonKey(defaultValue: [])
|
||||
late List<BannedUser> bans;
|
||||
|
||||
/// Create a new instance from a json
|
||||
static QueryBannedUsersResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$QueryBannedUsersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [channel.getReactions] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryReactionsResponse extends _BaseResponse {
|
||||
@@ -442,3 +455,43 @@ class ChannelStateResponse extends _BaseResponse {
|
||||
static ChannelStateResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$ChannelStateResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.enrichUrl] api call.
|
||||
@JsonSerializable(createToJson: false)
|
||||
class OGAttachmentResponse extends _BaseResponse {
|
||||
/// The URL of the page that was scraped.
|
||||
late String ogScrapeUrl;
|
||||
|
||||
/// The URL of the asset.
|
||||
String? assetUrl;
|
||||
|
||||
/// The URL of the author.
|
||||
String? authorLink;
|
||||
|
||||
/// The name of the author.
|
||||
String? authorName;
|
||||
|
||||
/// The URL of the image.
|
||||
String? imageUrl;
|
||||
|
||||
/// The text of the attachment.
|
||||
String? text;
|
||||
|
||||
/// The URL of the thumbnail.
|
||||
String? thumbUrl;
|
||||
|
||||
/// The title of the attachment.
|
||||
String? title;
|
||||
|
||||
/// The URL of the title.
|
||||
String? titleLink;
|
||||
|
||||
/// The type of the attachment.
|
||||
///
|
||||
/// 'video' | 'audio' | 'image'
|
||||
String? type;
|
||||
|
||||
/// Create a new instance from a [json].
|
||||
static OGAttachmentResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$OGAttachmentResponseFromJson(json);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,15 @@ QueryUsersResponse _$QueryUsersResponseFromJson(Map<String, dynamic> json) =>
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
QueryBannedUsersResponse _$QueryBannedUsersResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
QueryBannedUsersResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..bans = (json['bans'] as List<dynamic>?)
|
||||
?.map((e) => BannedUser.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
QueryReactionsResponse _$QueryReactionsResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
QueryReactionsResponse()
|
||||
@@ -273,3 +282,18 @@ ChannelStateResponse _$ChannelStateResponseFromJson(
|
||||
?.map((e) => Read.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
OGAttachmentResponse _$OGAttachmentResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
OGAttachmentResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..ogScrapeUrl = json['og_scrape_url'] as String
|
||||
..assetUrl = json['asset_url'] as String?
|
||||
..authorLink = json['author_link'] as String?
|
||||
..authorName = json['author_name'] as String?
|
||||
..imageUrl = json['image_url'] as String?
|
||||
..text = json['text'] as String?
|
||||
..thumbUrl = json['thumb_url'] as String?
|
||||
..title = json['title'] as String?
|
||||
..titleLink = json['title_link'] as String?
|
||||
..type = json['type'] as String?;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:stream_chat/src/core/error/chat_error_code.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:stream_chat/src/core/http/interceptor/connection_id_interceptor.
|
||||
import 'package:stream_chat/src/core/http/interceptor/logging_interceptor.dart';
|
||||
import 'package:stream_chat/src/core/http/stream_chat_dio_error.dart';
|
||||
import 'package:stream_chat/src/core/http/token_manager.dart';
|
||||
import 'package:stream_chat/src/location.dart';
|
||||
|
||||
part 'stream_http_client_options.dart';
|
||||
|
||||
|
||||
@@ -1,32 +1,20 @@
|
||||
part of 'stream_http_client.dart';
|
||||
|
||||
const _defaultBaseURL = 'https://chat-us-east-1.stream-io-api.com';
|
||||
const _defaultBaseURL = 'https://chat.stream-io-api.com';
|
||||
|
||||
/// Client options to modify [StreamHttpClient]
|
||||
class StreamHttpClientOptions {
|
||||
/// Instantiates a new [StreamHttpClientOptions]
|
||||
const StreamHttpClientOptions({
|
||||
String? baseUrl,
|
||||
this.location,
|
||||
this.connectTimeout = const Duration(seconds: 6),
|
||||
this.receiveTimeout = const Duration(seconds: 6),
|
||||
this.queryParameters = const {},
|
||||
this.headers = const {},
|
||||
}) : _baseUrl = baseUrl ?? _defaultBaseURL;
|
||||
|
||||
final String _baseUrl;
|
||||
}) : baseUrl = baseUrl ?? _defaultBaseURL;
|
||||
|
||||
/// base url to use with client.
|
||||
String get baseUrl {
|
||||
if (location == null) return _baseUrl;
|
||||
const serviceName = 'chat';
|
||||
final locationName = location!.name;
|
||||
const baseDomainName = 'stream-io-api.com';
|
||||
return 'https://$serviceName-proxy-$locationName.$baseDomainName';
|
||||
}
|
||||
|
||||
/// data center to use with client
|
||||
final Location? location;
|
||||
final String baseUrl;
|
||||
|
||||
/// connect timeout, default to 6s
|
||||
final Duration connectTimeout;
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart' show MultipartFile;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:stream_chat/src/core/platform_detector/platform_detector.dart';
|
||||
import 'package:stream_chat/src/core/util/extension.dart';
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/core/models/channel_model.dart';
|
||||
import 'package:stream_chat/src/core/models/user.dart';
|
||||
|
||||
part 'banned_user.g.dart';
|
||||
|
||||
/// Contains information about a [User] that was banned from a [Channel] or App.
|
||||
@JsonSerializable()
|
||||
class BannedUser extends Equatable {
|
||||
/// Creates a new instance of [BannedUser]
|
||||
const BannedUser({
|
||||
required this.user,
|
||||
this.bannedBy,
|
||||
this.channel,
|
||||
this.createdAt,
|
||||
this.expires,
|
||||
this.shadow = false,
|
||||
this.reason,
|
||||
});
|
||||
|
||||
/// Create a new instance from a json
|
||||
factory BannedUser.fromJson(Map<String, dynamic> json) =>
|
||||
_$BannedUserFromJson(json);
|
||||
|
||||
/// Banned user.
|
||||
final User user;
|
||||
|
||||
/// User that banned the [user].
|
||||
final User? bannedBy;
|
||||
|
||||
/// Channel where the [user] was banned.
|
||||
final ChannelModel? channel;
|
||||
|
||||
/// Timestamp when the [user] was banned.
|
||||
final DateTime? createdAt;
|
||||
|
||||
/// Timestamp when the [user] will be unbanned.
|
||||
final DateTime? expires;
|
||||
|
||||
/// Whether the [user] is a shadow banned user.
|
||||
final bool shadow;
|
||||
|
||||
/// Reason for the ban.
|
||||
final String? reason;
|
||||
|
||||
/// Serialize to json
|
||||
Map<String, dynamic> toJson() => _$BannedUserToJson(this);
|
||||
|
||||
/// Returns a copy of this object with the given fields updated.
|
||||
BannedUser copyWith({
|
||||
User? user,
|
||||
User? bannedBy,
|
||||
ChannelModel? channel,
|
||||
DateTime? createdAt,
|
||||
DateTime? expires,
|
||||
bool? shadow,
|
||||
String? reason,
|
||||
}) =>
|
||||
BannedUser(
|
||||
user: user ?? this.user,
|
||||
bannedBy: bannedBy ?? this.bannedBy,
|
||||
channel: channel ?? this.channel,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
expires: expires ?? this.expires,
|
||||
shadow: shadow ?? this.shadow,
|
||||
reason: reason ?? this.reason,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
user,
|
||||
bannedBy,
|
||||
channel,
|
||||
createdAt,
|
||||
expires,
|
||||
shadow,
|
||||
reason,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'banned_user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
BannedUser _$BannedUserFromJson(Map<String, dynamic> json) => BannedUser(
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
bannedBy: json['banned_by'] == null
|
||||
? null
|
||||
: User.fromJson(json['banned_by'] as Map<String, dynamic>),
|
||||
channel: json['channel'] == null
|
||||
? null
|
||||
: ChannelModel.fromJson(json['channel'] as Map<String, dynamic>),
|
||||
createdAt: json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String),
|
||||
expires: json['expires'] == null
|
||||
? null
|
||||
: DateTime.parse(json['expires'] as String),
|
||||
shadow: json['shadow'] as bool? ?? false,
|
||||
reason: json['reason'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BannedUserToJson(BannedUser instance) =>
|
||||
<String, dynamic>{
|
||||
'user': instance.user.toJson(),
|
||||
'banned_by': instance.bannedBy?.toJson(),
|
||||
'channel': instance.channel?.toJson(),
|
||||
'created_at': instance.createdAt?.toIso8601String(),
|
||||
'expires': instance.expires?.toIso8601String(),
|
||||
'shadow': instance.shadow,
|
||||
'reason': instance.reason,
|
||||
};
|
||||
@@ -7,6 +7,8 @@ import 'package:stream_chat/src/core/models/user.dart';
|
||||
|
||||
part 'channel_state.g.dart';
|
||||
|
||||
const _emptyPinnedMessages = <Message>[];
|
||||
|
||||
/// The class that contains the information about a channel
|
||||
@JsonSerializable()
|
||||
class ChannelState {
|
||||
@@ -15,7 +17,7 @@ class ChannelState {
|
||||
this.channel,
|
||||
this.messages = const [],
|
||||
this.members = const [],
|
||||
this.pinnedMessages = const [],
|
||||
this.pinnedMessages = _emptyPinnedMessages,
|
||||
this.watcherCount,
|
||||
this.watchers = const [],
|
||||
this.read = const [],
|
||||
@@ -63,7 +65,11 @@ class ChannelState {
|
||||
channel: channel ?? this.channel,
|
||||
messages: messages ?? this.messages,
|
||||
members: members ?? this.members,
|
||||
pinnedMessages: pinnedMessages ?? this.pinnedMessages,
|
||||
// Hack to avoid using the default value in case nothing is provided.
|
||||
// FIXME: Use non-nullable by default instead of empty list.
|
||||
pinnedMessages: pinnedMessages == _emptyPinnedMessages
|
||||
? this.pinnedMessages
|
||||
: pinnedMessages ?? _emptyPinnedMessages,
|
||||
watcherCount: watcherCount ?? this.watcherCount,
|
||||
watchers: watchers ?? this.watchers,
|
||||
read: read ?? this.read,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/core/models/channel_model.dart';
|
||||
import 'package:stream_chat/src/core/models/message.dart';
|
||||
import 'package:stream_chat/src/core/util/serializer.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class Member extends Equatable {
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
this.banned = false,
|
||||
this.banExpires,
|
||||
this.shadowBanned = false,
|
||||
}) : createdAt = createdAt ?? DateTime.now(),
|
||||
updatedAt = updatedAt ?? DateTime.now();
|
||||
@@ -56,6 +57,9 @@ class Member extends Equatable {
|
||||
/// True if the member is banned from the channel
|
||||
final bool banned;
|
||||
|
||||
/// The date at which the ban will expire.
|
||||
final DateTime? banExpires;
|
||||
|
||||
/// True if the member is shadow banned from the channel
|
||||
final bool shadowBanned;
|
||||
|
||||
@@ -77,6 +81,7 @@ class Member extends Equatable {
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
bool? banned,
|
||||
DateTime? banExpires,
|
||||
bool? shadowBanned,
|
||||
}) =>
|
||||
Member(
|
||||
@@ -85,6 +90,7 @@ class Member extends Equatable {
|
||||
inviteRejectedAt: inviteRejectedAt ?? this.inviteRejectedAt,
|
||||
invited: invited ?? this.invited,
|
||||
banned: banned ?? this.banned,
|
||||
banExpires: banExpires ?? this.banExpires,
|
||||
shadowBanned: shadowBanned ?? this.shadowBanned,
|
||||
role: role ?? this.role,
|
||||
userId: userId ?? this.userId,
|
||||
@@ -106,6 +112,7 @@ class Member extends Equatable {
|
||||
userId,
|
||||
isModerator,
|
||||
banned,
|
||||
banExpires,
|
||||
shadowBanned,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
|
||||
@@ -27,6 +27,9 @@ Member _$MemberFromJson(Map<String, dynamic> json) => Member(
|
||||
? null
|
||||
: DateTime.parse(json['updated_at'] as String),
|
||||
banned: json['banned'] as bool? ?? false,
|
||||
banExpires: json['ban_expires'] == null
|
||||
? null
|
||||
: DateTime.parse(json['ban_expires'] as String),
|
||||
shadowBanned: json['shadow_banned'] as bool? ?? false,
|
||||
);
|
||||
|
||||
@@ -39,6 +42,7 @@ Map<String, dynamic> _$MemberToJson(Member instance) => <String, dynamic>{
|
||||
'user_id': instance.userId,
|
||||
'is_moderator': instance.isModerator,
|
||||
'banned': instance.banned,
|
||||
'ban_expires': instance.banExpires?.toIso8601String(),
|
||||
'shadow_banned': instance.shadowBanned,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/core/models/device.dart';
|
||||
import 'package:stream_chat/src/core/models/mute.dart';
|
||||
import 'package:stream_chat/src/core/models/user.dart';
|
||||
import 'package:stream_chat/src/core/util/serializer.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
@@ -29,6 +26,7 @@ class OwnUser extends User {
|
||||
bool online = false,
|
||||
Map<String, Object?> extraData = const {},
|
||||
bool banned = false,
|
||||
DateTime? banExpires,
|
||||
List<String> teams = const [],
|
||||
String? language,
|
||||
}) : super(
|
||||
@@ -42,6 +40,7 @@ class OwnUser extends User {
|
||||
online: online,
|
||||
extraData: extraData,
|
||||
banned: banned,
|
||||
banExpires: banExpires,
|
||||
teams: teams,
|
||||
language: language,
|
||||
);
|
||||
@@ -78,6 +77,7 @@ class OwnUser extends User {
|
||||
bool? online,
|
||||
Map<String, Object?>? extraData,
|
||||
bool? banned,
|
||||
DateTime? banExpires,
|
||||
List<String>? teams,
|
||||
List<Mute>? channelMutes,
|
||||
List<Device>? devices,
|
||||
@@ -89,11 +89,12 @@ class OwnUser extends User {
|
||||
OwnUser(
|
||||
id: id ?? this.id,
|
||||
role: role ?? this.role,
|
||||
/* if null, it will be retrieved from extraData['name']*/
|
||||
// if null, it will be retrieved from extraData['name']
|
||||
name: name,
|
||||
/* if null, it will be retrieved from extraData['image']*/
|
||||
// if null, it will be retrieved from extraData['image']
|
||||
image: image,
|
||||
banned: banned ?? this.banned,
|
||||
banExpires: banExpires ?? this.banExpires,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
lastActive: lastActive ?? this.lastActive,
|
||||
@@ -139,7 +140,7 @@ class OwnUser extends User {
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<Mute> mutes;
|
||||
|
||||
/// List of users muted by the user.
|
||||
/// List of channels muted by the user.
|
||||
@JsonKey(includeIfNull: false)
|
||||
final List<Mute> channelMutes;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ OwnUser _$OwnUserFromJson(Map<String, dynamic> json) => OwnUser(
|
||||
online: json['online'] as bool? ?? false,
|
||||
extraData: json['extra_data'] as Map<String, dynamic>? ?? const {},
|
||||
banned: json['banned'] as bool? ?? false,
|
||||
banExpires: json['ban_expires'] == null
|
||||
? null
|
||||
: DateTime.parse(json['ban_expires'] as String),
|
||||
teams:
|
||||
(json['teams'] as List<dynamic>?)?.map((e) => e as String).toList() ??
|
||||
const [],
|
||||
|
||||
@@ -41,11 +41,12 @@ class User extends Equatable {
|
||||
Map<String, Object?> extraData = const {},
|
||||
this.online = false,
|
||||
this.banned = false,
|
||||
this.banExpires,
|
||||
this.teams = const [],
|
||||
this.language,
|
||||
}) : createdAt = createdAt ?? DateTime.now(),
|
||||
updatedAt = updatedAt ?? DateTime.now(),
|
||||
/*For backwards compatibility, set 'name', 'image' in [extraData].*/
|
||||
// For backwards compatibility, set 'name', 'image' in [extraData].
|
||||
extraData = {
|
||||
...extraData,
|
||||
if (name != null) 'name': name,
|
||||
@@ -67,6 +68,7 @@ class User extends Equatable {
|
||||
'last_active',
|
||||
'online',
|
||||
'banned',
|
||||
'ban_expires',
|
||||
'teams',
|
||||
'language',
|
||||
];
|
||||
@@ -129,14 +131,18 @@ class User extends Equatable {
|
||||
)
|
||||
final bool banned;
|
||||
|
||||
/// Map of custom user extraData.
|
||||
@JsonKey(includeIfNull: false)
|
||||
final Map<String, Object?> extraData;
|
||||
/// The date at which the ban will expire.
|
||||
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
|
||||
final DateTime? banExpires;
|
||||
|
||||
/// The language this user prefers.
|
||||
@JsonKey(includeIfNull: false)
|
||||
final String? language;
|
||||
|
||||
/// Map of custom user extraData.
|
||||
@JsonKey(includeIfNull: false)
|
||||
final Map<String, Object?> extraData;
|
||||
|
||||
/// List of users to list of userIds.
|
||||
static List<String>? toIds(List<User>? users) =>
|
||||
users?.map((u) => u.id).toList();
|
||||
@@ -158,15 +164,16 @@ class User extends Equatable {
|
||||
bool? online,
|
||||
Map<String, Object?>? extraData,
|
||||
bool? banned,
|
||||
DateTime? banExpires,
|
||||
List<String>? teams,
|
||||
String? language,
|
||||
}) =>
|
||||
User(
|
||||
id: id ?? this.id,
|
||||
role: role ?? this.role,
|
||||
/* if null, it will be retrieved from extraData['name']*/
|
||||
// if null, it will be retrieved from extraData['name']
|
||||
name: name,
|
||||
/* if null, it will be retrieved from extraData['image']*/
|
||||
// if null, it will be retrieved from extraData['image']
|
||||
image: image,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
@@ -174,6 +181,7 @@ class User extends Equatable {
|
||||
online: online ?? this.online,
|
||||
extraData: extraData ?? this.extraData,
|
||||
banned: banned ?? this.banned,
|
||||
banExpires: banExpires ?? this.banExpires,
|
||||
teams: teams ?? this.teams,
|
||||
language: language ?? this.language,
|
||||
);
|
||||
@@ -186,6 +194,7 @@ class User extends Equatable {
|
||||
online,
|
||||
extraData,
|
||||
banned,
|
||||
banExpires,
|
||||
teams,
|
||||
language,
|
||||
];
|
||||
|
||||
@@ -21,6 +21,9 @@ User _$UserFromJson(Map<String, dynamic> json) => User(
|
||||
extraData: json['extra_data'] as Map<String, dynamic>? ?? const {},
|
||||
online: json['online'] as bool? ?? false,
|
||||
banned: json['banned'] as bool? ?? false,
|
||||
banExpires: json['ban_expires'] == null
|
||||
? null
|
||||
: DateTime.parse(json['ban_expires'] as String),
|
||||
teams:
|
||||
(json['teams'] as List<dynamic>?)?.map((e) => e as String).toList() ??
|
||||
const [],
|
||||
@@ -45,7 +48,8 @@ Map<String, dynamic> _$UserToJson(User instance) {
|
||||
writeNotNull('last_active', readonly(instance.lastActive));
|
||||
writeNotNull('online', readonly(instance.online));
|
||||
writeNotNull('banned', readonly(instance.banned));
|
||||
val['extra_data'] = instance.extraData;
|
||||
writeNotNull('ban_expires', readonly(instance.banExpires));
|
||||
writeNotNull('language', instance.language);
|
||||
val['extra_data'] = instance.extraData;
|
||||
return val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user