Merge pull request #477 from GetStream/feat/modelTests

This commit is contained in:
Sahil Kumar
2021-06-17 15:47:22 +05:30
committed by GitHub
48 changed files with 2039 additions and 1654 deletions
@@ -1,2 +1,2 @@
export 'chat_error_code.dart';
export 'stream_chat_error.dart';
export 'stream_chat_error.dart';
@@ -78,8 +78,7 @@ class ChannelModel {
final DateTime? deletedAt;
/// The count of this channel members
@JsonKey(
includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
final int memberCount;
/// Map of custom channel extraData
@@ -1,3 +1,5 @@
import 'dart:convert';
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';
@@ -160,11 +162,14 @@ class Event {
channelType: channelType ?? this.channelType,
parentId: parentId ?? this.parentId,
extraData: extraData ?? this.extraData,
isLocal: isLocal,
);
}
/// The channel embedded in the event object
@JsonSerializable()
@JsonSerializable(
createToJson: false,
)
class EventChannel extends ChannelModel {
/// Constructor used for json serialization
EventChannel({
@@ -212,10 +217,4 @@ class EventChannel extends ChannelModel {
'members',
...ChannelModel.topLevelFields,
];
/// Serialize to json
@override
Map<String, dynamic> toJson() => Serializer.moveFromExtraDataToRoot(
_$EventChannelToJson(this),
);
}
@@ -89,29 +89,3 @@ EventChannel _$EventChannelFromJson(Map<String, dynamic> json) {
extraData: json['extra_data'] as Map<String, dynamic>? ?? {},
);
}
Map<String, dynamic> _$EventChannelToJson(EventChannel instance) {
final val = <String, dynamic>{
'id': instance.id,
'type': instance.type,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('cid', readonly(instance.cid));
writeNotNull('config', readonly(instance.config));
writeNotNull('created_by', readonly(instance.createdBy));
val['frozen'] = instance.frozen;
writeNotNull('last_message_at', readonly(instance.lastMessageAt));
writeNotNull('created_at', readonly(instance.createdAt));
writeNotNull('updated_at', readonly(instance.updatedAt));
writeNotNull('deleted_at', readonly(instance.deletedAt));
writeNotNull('member_count', readonly(instance.memberCount));
val['extra_data'] = instance.extraData;
val['members'] = instance.members?.map((e) => e.toJson()).toList();
return val;
}
@@ -1,12 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:stream_chat/src/core/util/serializer.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:stream_chat/src/core/util/serializer.dart';
part 'mute.g.dart';
/// The class that contains the information about a muted user
@JsonSerializable()
@JsonSerializable(createToJson: false)
class Mute {
/// Constructor used for json serialization
Mute({
@@ -34,7 +34,4 @@ class Mute {
/// The date of the last update
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
final DateTime updatedAt;
/// Serialize to json
Map<String, dynamic> toJson() => _$MuteToJson(this);
}
@@ -14,19 +14,3 @@ Mute _$MuteFromJson(Map<String, dynamic> json) {
updatedAt: DateTime.parse(json['updated_at'] as String),
);
}
Map<String, dynamic> _$MuteToJson(Mute instance) {
final val = <String, dynamic>{};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('user', readonly(instance.user));
writeNotNull('channel', readonly(instance.channel));
writeNotNull('created_at', readonly(instance.createdAt));
writeNotNull('updated_at', readonly(instance.updatedAt));
return val;
}
@@ -1,14 +1,14 @@
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/util/serializer.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:stream_chat/src/core/util/serializer.dart';
part 'own_user.g.dart';
/// The class that defines the own user model
/// This object can be found in [Event]
@JsonSerializable()
@JsonSerializable(createToJson: false)
class OwnUser extends User {
/// Constructor used for json serialization
OwnUser({
@@ -53,33 +53,23 @@ class OwnUser extends User {
);
/// List of user devices
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
defaultValue: <Device>[])
@JsonKey(includeIfNull: false, defaultValue: <Device>[])
final List<Device> devices;
/// List of users muted by the user
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
defaultValue: <Mute>[])
@JsonKey(includeIfNull: false, defaultValue: <Mute>[])
final List<Mute> mutes;
/// List of users muted by the user
@JsonKey(
includeIfNull: false,
toJson: Serializer.readOnly,
defaultValue: <Mute>[])
@JsonKey(includeIfNull: false, defaultValue: <Mute>[])
final List<Mute> channelMutes;
/// Total unread messages by the user
@JsonKey(
includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0)
@JsonKey(includeIfNull: false, defaultValue: 0)
final int totalUnreadCount;
/// Total unread channels by the user
@JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
@JsonKey(includeIfNull: false)
final int? unreadChannels;
/// Known top level fields.
@@ -92,10 +82,4 @@ class OwnUser extends User {
'channel_mutes',
...User.topLevelFields,
];
/// Serialize to json
@override
Map<String, dynamic> toJson() => Serializer.moveFromExtraDataToRoot(
_$OwnUserToJson(this),
);
}
@@ -38,29 +38,3 @@ OwnUser _$OwnUserFromJson(Map<String, dynamic> json) {
banned: json['banned'] as bool? ?? false,
);
}
Map<String, dynamic> _$OwnUserToJson(OwnUser instance) {
final val = <String, dynamic>{
'id': instance.id,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('role', readonly(instance.role));
writeNotNull('created_at', readonly(instance.createdAt));
writeNotNull('updated_at', readonly(instance.updatedAt));
writeNotNull('last_active', readonly(instance.lastActive));
writeNotNull('online', readonly(instance.online));
writeNotNull('banned', readonly(instance.banned));
val['extra_data'] = instance.extraData;
writeNotNull('devices', readonly(instance.devices));
writeNotNull('mutes', readonly(instance.mutes));
writeNotNull('channel_mutes', readonly(instance.channelMutes));
writeNotNull('total_unread_count', readonly(instance.totalUnreadCount));
writeNotNull('unread_channels', readonly(instance.unreadChannels));
return val;
}
@@ -22,8 +22,8 @@ class User extends Equatable {
updatedAt = updatedAt ?? DateTime.now();
/// Create a new instance from a json
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(
Serializer.moveToExtraDataFromRoot(json, topLevelFields));
factory User.fromJson(Map<String, dynamic> json) =>
_$UserFromJson(Serializer.moveToExtraDataFromRoot(json, topLevelFields));
/// Known top level fields.
/// Useful for [Serializer] methods.
+7
View File
@@ -0,0 +1,7 @@
{
"name": "name",
"style": "style",
"text": "text",
"type": "type",
"value": "value"
}
+29
View File
@@ -0,0 +1,29 @@
{
"type": "giphy",
"title": "awesome",
"title_link": "https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti",
"thumb_url": "https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif",
"actions": [
{
"name": "image_action",
"text": "Send",
"style": "primary",
"type": "button",
"value": "send"
},
{
"name": "image_action",
"text": "Shuffle",
"style": "default",
"type": "button",
"value": "shuffle"
},
{
"name": "image_action",
"text": "Cancel",
"style": "default",
"type": "button",
"value": "cancel"
}
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"id": "test",
"type": "livestream",
"cid": "livestream:test",
"cats": true,
"fruit": ["bananas", "apples"]
}
+832
View File
@@ -0,0 +1,832 @@
{
"channel": {
"id": "dev",
"type": "team",
"cid": "team:dev",
"last_message_at": "2020-01-30T13:43:41.062362Z",
"created_at": "2019-04-03T18:43:33.213373Z",
"updated_at": "2019-04-03T18:43:33.213374Z",
"team": "test",
"created_by": {
"id": "guido",
"role": "user",
"created_at": "2019-04-03T18:43:33.201036Z",
"updated_at": "2019-04-03T18:43:33.204713Z",
"banned": false,
"online": false,
"name": "Guido"
},
"frozen": true,
"config": {
"created_at": "2019-11-07T22:29:26.776526Z",
"updated_at": "2019-11-07T22:29:48.286746Z",
"name": "team",
"typing_events": true,
"read_events": true,
"connect_events": true,
"search": true,
"reactions": true,
"replies": true,
"mutes": true,
"uploads": true,
"url_enrichment": true,
"message_retention": "infinite",
"max_message_length": 5000,
"automod": "disabled",
"automod_behavior": "flag",
"commands": [
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
"set": "fun_set"
}
]
},
"name": "#dev",
"image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png",
"example": 1
},
"messages": [
{
"id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030",
"text": "fasdfa",
"type": "regular",
"status": "SENT",
"silent": false,
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:23:02.843948Z",
"updated_at": "2020-01-29T03:23:02.843949Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f",
"text": "test message",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:23:07.981091Z",
"updated_at": "2020-01-29T03:23:07.981091Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0",
"text": "test message",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:23:11.568022Z",
"updated_at": "2020-01-29T03:23:11.568022Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35",
"text": "asdfadf",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:32:57.403566Z",
"updated_at": "2020-01-29T03:32:57.403566Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe",
"text": "test",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:33:35.294802Z",
"updated_at": "2020-01-29T03:33:35.294802Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc",
"text": "hi",
"type": "regular",
"user": {
"id": "withered-cell-0",
"role": "user",
"created_at": "2020-01-29T03:34:01.698106Z",
"updated_at": "2020-01-29T03:34:01.708808Z",
"last_active": "2020-01-29T03:34:01.70353Z",
"banned": false,
"online": false,
"name": "Withered cell",
"image": "https://getstream.io/random_svg/?name=Withered+cell"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:34:27.393296Z",
"updated_at": "2020-01-29T03:34:27.393296Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53",
"text": "fantastic",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:34:37.638376Z",
"updated_at": "2020-01-29T03:34:37.638376Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240",
"text": "nice to meet you",
"type": "regular",
"user": {
"id": "withered-cell-0",
"role": "user",
"created_at": "2020-01-29T03:34:01.698106Z",
"updated_at": "2020-01-29T03:34:01.708808Z",
"last_active": "2020-01-29T03:34:01.70353Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Withered+cell",
"name": "Withered cell"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:35:04.301566Z",
"updated_at": "2020-01-29T03:35:04.301566Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42",
"text": "hey",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:35:24.939084Z",
"updated_at": "2020-01-29T03:35:24.939085Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa",
"text": "hello, everyone",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"name": "Dry meadow",
"image": "https://getstream.io/random_svg/?name=Dry+meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:35:33.101566Z",
"updated_at": "2020-01-29T03:35:33.101566Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0",
"text": "who is there?",
"type": "regular",
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"name": "Dry meadow",
"image": "https://getstream.io/random_svg/?name=Dry+meadow"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T03:35:45.458685Z",
"updated_at": "2020-01-29T03:35:45.458685Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356",
"text": "하이",
"type": "regular",
"user": {
"id": "icy-recipe-7",
"role": "user",
"created_at": "2020-01-21T11:36:22.284503Z",
"updated_at": "2020-01-29T07:01:59.69882Z",
"last_active": "2020-01-29T07:01:59.693378Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Icy+recipe",
"name": "Icy recipe"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T07:02:11.535395Z",
"updated_at": "2020-01-29T07:02:11.535395Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055",
"text": "what are you doing?",
"type": "regular",
"user": {
"id": "icy-recipe-7",
"role": "user",
"created_at": "2020-01-21T11:36:22.284503Z",
"updated_at": "2020-01-29T07:01:59.69882Z",
"last_active": "2020-01-29T07:01:59.693378Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Icy+recipe",
"name": "Icy recipe"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T07:02:22.485136Z",
"updated_at": "2020-01-29T07:02:22.485136Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4",
"text": "👍",
"type": "regular",
"user": {
"id": "throbbing-boat-5",
"role": "user",
"created_at": "2019-07-30T06:29:53.060413Z",
"updated_at": "2020-01-29T14:11:27.80176Z",
"last_active": "2020-01-29T14:11:27.7963Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Throbbing+boat",
"name": "Throbbing boat"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T14:12:04.688552Z",
"updated_at": "2020-01-29T14:12:04.688552Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21",
"text": "sdasas",
"type": "regular",
"user": {
"id": "snowy-credit-3",
"role": "user",
"created_at": "2020-01-29T15:29:03.693312Z",
"updated_at": "2020-01-29T15:29:03.702648Z",
"last_active": "2020-01-29T15:29:03.696144Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Snowy+credit",
"name": "Snowy credit"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T15:29:36.011315Z",
"updated_at": "2020-01-29T15:29:36.011316Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d",
"text": "cjshsa",
"type": "regular",
"user": {
"id": "snowy-credit-3",
"role": "user",
"created_at": "2020-01-29T15:29:03.693312Z",
"updated_at": "2020-01-29T15:29:03.702648Z",
"last_active": "2020-01-29T15:29:03.696144Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Snowy+credit",
"name": "Snowy credit"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T15:29:41.677819Z",
"updated_at": "2020-01-29T15:29:41.677819Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d",
"text": "nhisagdhsadz",
"type": "regular",
"user": {
"id": "snowy-credit-3",
"role": "user",
"created_at": "2020-01-29T15:29:03.693312Z",
"updated_at": "2020-01-29T15:29:03.702648Z",
"last_active": "2020-01-29T15:29:03.696144Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Snowy+credit",
"name": "Snowy credit"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T15:29:43.354177Z",
"updated_at": "2020-01-29T15:29:43.354177Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3",
"text": "hvadhsahzd",
"type": "regular",
"user": {
"id": "snowy-credit-3",
"role": "user",
"created_at": "2020-01-29T15:29:03.693312Z",
"updated_at": "2020-01-29T15:29:03.702648Z",
"last_active": "2020-01-29T15:29:03.696144Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Snowy+credit",
"name": "Snowy credit"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T15:29:44.754713Z",
"updated_at": "2020-01-29T15:29:44.754713Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf",
"text": "hello",
"type": "regular",
"user": {
"id": "divine-glade-9",
"role": "user",
"created_at": "2020-01-29T17:02:18.312524Z",
"updated_at": "2020-01-29T17:02:18.320187Z",
"last_active": "2020-01-29T17:02:18.315074Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Divine+glade",
"name": "Divine glade"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T17:02:36.933852Z",
"updated_at": "2020-01-29T17:02:36.933852Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73",
"text": "hello",
"type": "regular",
"user": {
"id": "red-firefly-9",
"role": "user",
"created_at": "2019-08-02T18:56:39.366516Z",
"updated_at": "2020-01-29T22:13:50.491769Z",
"last_active": "2020-01-29T22:13:50.450215Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Red+firefly",
"name": "Red firefly"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-29T22:14:08.54062Z",
"updated_at": "2020-01-29T22:14:08.54062Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854",
"text": "hello",
"type": "regular",
"user": {
"id": "bitter-glade-2",
"role": "user",
"created_at": "2020-01-30T13:08:56.190678Z",
"updated_at": "2020-01-30T13:08:56.200333Z",
"last_active": "2020-01-30T13:08:56.193882Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Bitter+glade",
"name": "Bitter glade"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-30T13:11:37.191293Z",
"updated_at": "2020-01-30T13:11:37.191293Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480",
"text": "http://jaeger.ui.gtstrm.com/",
"type": "regular",
"user": {
"id": "morning-sea-1",
"role": "user",
"created_at": "2019-07-22T09:19:07.505207Z",
"updated_at": "2020-01-30T13:33:05.831856Z",
"last_active": "2020-01-30T13:33:05.825369Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Morning+sea",
"name": "Morning sea"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-30T13:33:16.853116Z",
"updated_at": "2020-01-30T13:33:16.853116Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be",
"text": "hi",
"type": "regular",
"user": {
"id": "ancient-salad-0",
"role": "user",
"created_at": "2020-01-30T13:34:29.286813Z",
"updated_at": "2020-01-30T13:34:29.296196Z",
"last_active": "2020-01-30T13:34:29.289964Z",
"banned": false,
"online": true,
"image": "https://getstream.io/random_svg/?name=Ancient+salad",
"name": "Ancient salad"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-30T13:36:52.749731Z",
"updated_at": "2020-01-30T13:36:52.749732Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40",
"text": "hi",
"type": "regular",
"user": {
"id": "ancient-salad-0",
"role": "user",
"created_at": "2020-01-30T13:34:29.286813Z",
"updated_at": "2020-01-30T13:34:29.296196Z",
"last_active": "2020-01-30T13:34:29.289964Z",
"banned": false,
"online": true,
"image": "https://getstream.io/random_svg/?name=Ancient+salad",
"name": "Ancient salad"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-30T13:37:41.631056Z",
"updated_at": "2020-01-30T13:37:41.631056Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c",
"text": "😃",
"type": "regular",
"user": {
"id": "proud-sea-7",
"role": "user",
"created_at": "2020-01-30T13:43:03.903006Z",
"updated_at": "2020-01-30T13:43:03.912307Z",
"last_active": "2020-01-30T13:43:03.906236Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Proud+sea",
"name": "Proud sea"
},
"attachments": [],
"latest_reactions": [],
"own_reactions": [],
"reaction_counts": {},
"reaction_scores": {},
"reply_count": 0,
"created_at": "2020-01-30T13:43:41.062362Z",
"updated_at": "2020-01-30T13:43:41.062362Z",
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
}
],
"watcher_count": 5,
"members": []
}
@@ -0,0 +1,418 @@
{
"channel": {
"id": "dev",
"type": "team",
"frozen": true,
"name": "#dev",
"image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png",
"example": 1
},
"watchers": [],
"read": [],
"messages": [
{
"id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030",
"text": "fasdfa",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f",
"text": "test message",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0",
"text": "test message",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35",
"text": "asdfadf",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe",
"text": "test",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc",
"text": "hi",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53",
"text": "fantastic",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240",
"text": "nice to meet you",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42",
"text": "hey",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa",
"text": "hello, everyone",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0",
"text": "who is there?",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356",
"text": "하이",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055",
"text": "what are you doing?",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4",
"text": "👍",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21",
"text": "sdasas",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d",
"text": "cjshsa",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d",
"text": "nhisagdhsadz",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3",
"text": "hvadhsahzd",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf",
"text": "hello",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73",
"text": "hello",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854",
"text": "hello",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480",
"text": "http://jaeger.ui.gtstrm.com/",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be",
"text": "hi",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40",
"text": "hi",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
},
{
"id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c",
"text": "😃",
"attachments": [],
"parent_id": null,
"quoted_message": null,
"quoted_message_id": null,
"show_in_channel": null,
"mentioned_users": [],
"status": "SENT",
"silent": false,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null
}
],
"pinned_messages": [],
"members": [],
"watcher_count": 5
}
+5
View File
@@ -0,0 +1,5 @@
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]"
}
+4
View File
@@ -0,0 +1,4 @@
{
"id": "device-id",
"push_provider": "push-provider"
}
+29
View File
@@ -0,0 +1,29 @@
{
"type": "type",
"cid": "cid",
"connection_id": "connectionId",
"created_at": "2019-04-03T18:43:33.213374Z",
"me": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"parent_id": null,
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
}
}
+99
View File
@@ -0,0 +1,99 @@
{
"id": "!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU",
"type": "messaging",
"cid": "messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU",
"last_message_at": "2020-12-02T04:22:16.755334Z",
"created_at": "2020-10-01T08:49:32.90162Z",
"updated_at": "2021-06-17T08:18:48.188996Z",
"created_by": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-17T08:12:05.062115Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"frozen": false,
"disabled": false,
"members": [
{
"user_id": "super-band-9",
"user": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-17T08:12:05.062115Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"role": "owner",
"created_at": "2020-10-01T08:49:32.905052Z",
"updated_at": "2020-10-01T08:49:32.905052Z",
"banned": false,
"shadow_banned": false
},
{
"user_id": "cc48de8e-b2db-48e7-bba5-c03cefd61430",
"user": {
"id": "cc48de8e-b2db-48e7-bba5-c03cefd61430",
"role": "user",
"created_at": "2020-07-22T14:59:38.026809Z",
"updated_at": "2020-07-22T14:59:38.31338Z",
"banned": false,
"online": false,
"image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA3NjYzMzE1MV5BMl5BanBnXkFtZTgwNTA4NDY4OTE@._V1_UX172_CR0,0,172,256_AL_.jpg",
"name": "Ana De Armas"
},
"role": "member",
"created_at": "2020-10-01T08:49:32.905053Z",
"updated_at": "2020-10-01T08:49:32.905053Z",
"banned": false,
"shadow_banned": false
}
],
"member_count": 2,
"config": {
"created_at": "2020-04-15T14:57:17.00966Z",
"updated_at": "2021-05-25T14:25:30.405621Z",
"name": "messaging",
"typing_events": true,
"read_events": true,
"connect_events": true,
"search": true,
"reactions": true,
"replies": true,
"mutes": true,
"uploads": true,
"url_enrichment": true,
"custom_events": false,
"push_notifications": true,
"message_retention": "infinite",
"max_message_length": 5000,
"automod": "disabled",
"automod_behavior": "flag",
"blocklist": "profanity_en_2020_v1",
"blocklist_behavior": "block",
"automod_thresholds": {},
"commands": [
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
"set": "fun_set"
}
]
},
"name": "test"
}
+15
View File
@@ -0,0 +1,15 @@
{
"user": {
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e",
"role": "user",
"created_at": "2020-01-28T22:17:30.826259Z",
"updated_at": "2020-01-28T22:17:31.101222Z",
"banned": false,
"online": false,
"name": "Robin Papa",
"image": "https://pbs.twimg.com/profile_images/669512187778498560/L7wQctBt.jpg"
},
"role": "member",
"created_at": "2020-01-28T22:17:30.95443Z",
"updated_at": "2020-01-28T22:17:30.95443Z"
}
+65
View File
@@ -0,0 +1,65 @@
{
"id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"type": "regular",
"silent": false,
"status": "SENT",
"user": {
"id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"role": "user",
"created_at": "2020-01-28T22:17:30.83015Z",
"updated_at": "2020-01-28T22:17:31.19435Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/2.jpg",
"name": "Mia Denys"
},
"attachments": [
{
"type": "video",
"author_name": "GIPHY",
"title": "The Lion King Disney GIF - Find \u0026 Share on GIPHY",
"title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"text": "Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.",
"image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4",
"og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA"
}
],
"latest_reactions": [
{
"message_id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"user_id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"user": {
"id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"role": "user",
"created_at": "2020-01-28T22:17:30.83015Z",
"updated_at": "2020-01-28T22:17:31.19435Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/2.jpg",
"name": "Mia Denys"
},
"type": "love",
"score": 1,
"created_at": "2020-01-28T22:17:31.128376Z",
"updated_at": "2020-01-28T22:17:31.128376Z"
}
],
"own_reactions": [],
"reaction_counts": {
"love": 1
},
"reaction_scores": {
"love": 1
},
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null,
"reply_count": 0,
"created_at": "2020-01-28T22:17:31.107978Z",
"updated_at": "2020-01-28T22:17:31.130506Z",
"mentioned_users": []
}
+29
View File
@@ -0,0 +1,29 @@
{
"id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"silent": false,
"attachments": [
{
"type": "video",
"title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"title": "The Lion King Disney GIF - Find & Share on GIPHY",
"thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"text": "Discover & share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.",
"og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"author_name": "GIPHY",
"asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4",
"actions": []
}
],
"mentioned_users": [],
"parent_id": "parentId",
"quoted_message": null,
"quoted_message_id": null,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null,
"show_in_channel": true,
"hey": "test"
}
+74
View File
@@ -0,0 +1,74 @@
{
"user": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-16T11:42:29.466165498Z",
"banned": false,
"online": true,
"username": "Rioland",
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0
},
"channel": {
"id": "!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
"type": "messaging",
"cid": "messaging:!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
"last_message_at": "2020-12-02T06:56:18.003432Z",
"created_at": "2020-11-30T10:25:32.494601Z",
"updated_at": "2020-11-30T10:25:32.494601Z",
"created_by": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-16T11:42:29.466165498Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"frozen": false,
"disabled": false,
"member_count": 2,
"config": {
"created_at": "2020-04-15T14:57:17.00966Z",
"updated_at": "2021-05-25T14:25:30.405621Z",
"name": "messaging",
"typing_events": true,
"read_events": true,
"connect_events": true,
"search": true,
"reactions": true,
"replies": true,
"mutes": true,
"uploads": true,
"url_enrichment": true,
"custom_events": false,
"push_notifications": true,
"message_retention": "infinite",
"max_message_length": 5000,
"automod": "disabled",
"automod_behavior": "flag",
"blocklist": "profanity_en_2020_v1",
"blocklist_behavior": "block",
"automod_thresholds": {},
"commands": [
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
"set": "fun_set"
}
]
}
},
"created_at": "2020-12-04T10:39:06.512021Z",
"updated_at": "2020-12-04T10:39:06.512021Z"
}
+100
View File
@@ -0,0 +1,100 @@
{
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-16T11:59:59.003453014Z",
"banned": false,
"online": true,
"devices": [
{
"push_provider": "firebase",
"id": "cRS8elU4Q-qqdCAvHR2kSa:APA91bFy7MEgPyXbnFWi3uoanr_x8Vbi42JcWOXlg8p3vyIL5FuW4bjpVfamqQjYCgwDGxPA0C4qavOadE-uiKeGQJp6Sp5D2KDW9Od_BlDqzwEPJnVG9gC1zbj7NKCfXRqbOA2Wh2mW",
"created_at": "2020-04-23T14:36:21.838196Z",
"user_id": "super-band-9"
}
],
"mutes": [],
"channel_mutes": [
{
"user": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-16T11:59:59.003453014Z",
"banned": false,
"online": true,
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness",
"unread_count": 0,
"username": "Rioland"
},
"channel": {
"id": "!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
"type": "messaging",
"cid": "messaging:!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw",
"last_message_at": "2020-12-02T06:56:18.003432Z",
"created_at": "2020-11-30T10:25:32.494601Z",
"updated_at": "2020-11-30T10:25:32.494601Z",
"created_by": {
"id": "super-band-9",
"role": "user",
"created_at": "2020-03-03T16:48:28.853674Z",
"updated_at": "2021-05-26T03:22:20.296181Z",
"last_active": "2021-06-16T11:59:59.003453014Z",
"banned": false,
"online": true,
"unread_count": 0,
"username": "Rioland",
"image": "https://placehold.jp/150x150.png",
"invisible": false,
"name": "Proud darkness"
},
"frozen": false,
"disabled": false,
"member_count": 2,
"config": {
"created_at": "2020-04-15T14:57:17.00966Z",
"updated_at": "2021-05-25T14:25:30.405621Z",
"name": "messaging",
"typing_events": true,
"read_events": true,
"connect_events": true,
"search": true,
"reactions": true,
"replies": true,
"mutes": true,
"uploads": true,
"url_enrichment": true,
"custom_events": false,
"push_notifications": true,
"message_retention": "infinite",
"max_message_length": 5000,
"automod": "disabled",
"automod_behavior": "flag",
"blocklist": "profanity_en_2020_v1",
"blocklist_behavior": "block",
"automod_thresholds": {},
"commands": [
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
"set": "fun_set"
}
]
}
},
"created_at": "2020-12-04T10:39:06.512021Z",
"updated_at": "2020-12-04T10:39:06.512021Z"
}
],
"total_unread_count": 0,
"unread_channels": 0,
"language": "",
"image": "https://placehold.jp/150x150.png",
"name": "Proud darkness",
"username": "Rioland"
}
+18
View File
@@ -0,0 +1,18 @@
{
"message_id": "76cd8c82-b557-4e48-9d12-87995d3a0e04",
"user_id": "2de0297c-f3f2-489d-b930-ef77342edccf",
"user": {
"id": "2de0297c-f3f2-489d-b930-ef77342edccf",
"role": "user",
"created_at": "2020-01-28T22:17:30.810011Z",
"updated_at": "2020-01-28T22:17:31.077195Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/45.jpg",
"name": "Daisy Morgan"
},
"type": "wow",
"score": 1,
"created_at": "2020-01-28T22:17:31.108742Z",
"updated_at": "2020-01-28T22:17:31.108742Z"
}
+7
View File
@@ -0,0 +1,7 @@
{
"user": {
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e"
},
"last_read": "2020-01-28T22:17:30.966485504Z",
"unread_messages": 10
}
+5
View File
@@ -0,0 +1,5 @@
{
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e",
"role": "test-role",
"name": "John"
}
@@ -1,21 +1,12 @@
import 'dart:convert';
import 'package:test/test.dart';
import 'package:stream_chat/src/core/models/action.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/action', () {
const jsonExample = '''
{
"name": "name",
"style": "style",
"text": "text",
"type": "type",
"value": "value"
}''';
test('should parse json correctly', () {
final action = Action.fromJson(json.decode(jsonExample));
final action = Action.fromJson(jsonFixture('action.json'));
expect(action.name, 'name');
expect(action.style, 'style');
expect(action.text, 'text');
@@ -1,44 +1,13 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/action.dart';
import 'package:stream_chat/src/core/models/attachment.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/attachment', () {
const jsonExample = '''
{
"type": "giphy",
"title": "awesome",
"title_link": "https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti",
"thumb_url": "https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif",
"actions": [
{
"name": "image_action",
"text": "Send",
"style": "primary",
"type": "button",
"value": "send"
},
{
"name": "image_action",
"text": "Shuffle",
"style": "default",
"type": "button",
"value": "shuffle"
},
{
"name": "image_action",
"text": "Cancel",
"style": "default",
"type": "button",
"value": "cancel"
}
]
}''';
test('should parse json correctly', () {
final attachment = Attachment.fromJson(json.decode(jsonExample));
final attachment = Attachment.fromJson(jsonFixture('attachment.json'));
expect(attachment.type, 'giphy');
expect(attachment.title, 'awesome');
expect(
File diff suppressed because it is too large Load Diff
@@ -1,22 +1,12 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/channel', () {
const jsonExample = '''
{
"id": "test",
"type": "livestream",
"cid": "livestream:test",
"cats": true,
"fruit": ["bananas", "apples"]
}
''';
test('should parse json correctly', () {
final channel = ChannelModel.fromJson(json.decode(jsonExample));
final channel = ChannelModel.fromJson(jsonFixture('channel.json'));
expect(channel.id, equals('test'));
expect(channel.type, equals('livestream'));
expect(channel.cid, equals('livestream:test'));
@@ -1,20 +1,12 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/command.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/command', () {
const jsonExample = '''
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]"
}
''';
test('should parse json correctly', () {
final command = Command.fromJson(json.decode(jsonExample));
final command = Command.fromJson(jsonFixture('command.json'));
expect(command.name, 'giphy');
expect(command.description, 'Post a random gif to the channel');
expect(command.args, '[text]');
@@ -1,18 +1,12 @@
import 'dart:convert';
import 'package:test/test.dart';
import 'package:stream_chat/src/core/models/device.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/device', () {
const jsonExample = '''
{
"id": "device-id",
"push_provider": "push-provider"
}''';
test('should parse json correctly', () {
final device = Device.fromJson(json.decode(jsonExample));
final device = Device.fromJson(jsonFixture('device.json'));
expect(device.id, 'device-id');
expect(device.pushProvider, 'push-provider');
});
@@ -1,46 +1,14 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/event.dart';
import 'package:stream_chat/src/core/models/own_user.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/event', () {
const jsonExample = '''
{
"type": "type",
"cid": "cid",
"connection_id": "connectionId",
"created_at": "2019-04-03T18:43:33.213374Z",
"me": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
},
"parent_id": null,
"user": {
"id": "dry-meadow-0",
"role": "user",
"created_at": "2019-03-27T17:40:17.155892Z",
"updated_at": "2020-01-29T03:22:47.641589Z",
"last_active": "2020-01-29T03:22:47.63613Z",
"banned": false,
"online": false,
"image": "https://getstream.io/random_svg/?name=Dry+meadow",
"name": "Dry meadow"
}
}
''';
test('should parse json correctly', () {
final event = Event.fromJson(json.decode(jsonExample));
final event = Event.fromJson(jsonFixture('event.json'));
expect(event.type, 'type');
expect(event.cid, 'cid');
expect(event.connectionId, 'connectionId');
@@ -86,5 +54,53 @@ void main() {
},
);
});
test('copyWith', () {
final event = Event.fromJson(jsonFixture('event.json'));
var newEvent = event.copyWith();
expect(newEvent.type, 'type');
expect(newEvent.cid, 'cid');
expect(newEvent.connectionId, 'connectionId');
expect(newEvent.createdAt, isA<DateTime>());
expect(newEvent.me, isA<OwnUser>());
expect(newEvent.user, isA<User>());
expect(newEvent.isLocal, false);
newEvent = event.copyWith(
type: 'test',
cid: 'test',
connectionId: 'test',
extraData: {},
user: User(id: 'test'),
channelId: 'test',
totalUnreadCount: 2,
channelType: 'testtype',
);
expect(newEvent.channelType, 'testtype');
expect(newEvent.totalUnreadCount, 2);
expect(newEvent.type, 'test');
expect(newEvent.channelId, 'test');
expect(newEvent.cid, 'test');
expect(newEvent.connectionId, 'test');
expect(newEvent.extraData, {});
expect(newEvent.user!.id, 'test');
});
group('eventChannel', () {
test('should parse json correctly', () {
final eventChannel =
EventChannel.fromJson(jsonFixture('event_channel.json'));
expect(eventChannel.type, 'messaging');
expect(eventChannel.cid,
'messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU');
expect(eventChannel.createdBy!.id, 'super-band-9');
expect(eventChannel.frozen, false);
expect(eventChannel.members!.length, 2);
expect(eventChannel.memberCount, 2);
expect(eventChannel.config, isA<ChannelConfig>());
expect(eventChannel.name, 'test');
});
});
});
}
@@ -1,31 +1,13 @@
import 'dart:convert';
import 'package:test/test.dart';
import 'package:stream_chat/src/core/models/member.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/member', () {
const jsonExample = '''
{
"user": {
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e",
"role": "user",
"created_at": "2020-01-28T22:17:30.826259Z",
"updated_at": "2020-01-28T22:17:31.101222Z",
"banned": false,
"online": false,
"name": "Robin Papa",
"image": "https://pbs.twimg.com/profile_images/669512187778498560/L7wQctBt.jpg"
},
"role": "member",
"created_at": "2020-01-28T22:17:30.95443Z",
"updated_at": "2020-01-28T22:17:30.95443Z"
}
''';
test('should parse json correctly', () {
final member = Member.fromJson(json.decode(jsonExample));
final member = Member.fromJson(jsonFixture('member.json'));
expect(member.user, isA<User>());
expect(member.role, 'member');
expect(member.createdAt, DateTime.parse('2020-01-28T22:17:30.95443Z'));
@@ -1,82 +1,15 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/attachment.dart';
import 'package:stream_chat/src/core/models/message.dart';
import 'package:stream_chat/src/core/models/reaction.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/message', () {
const jsonExample = r'''
{
"id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"type": "regular",
"silent": false,
"status": "SENT",
"user": {
"id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"role": "user",
"created_at": "2020-01-28T22:17:30.83015Z",
"updated_at": "2020-01-28T22:17:31.19435Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/2.jpg",
"name": "Mia Denys"
},
"attachments": [
{
"type": "video",
"author_name": "GIPHY",
"title": "The Lion King Disney GIF - Find \u0026 Share on GIPHY",
"title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"text": "Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.",
"image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4",
"og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA"
}
],
"latest_reactions": [
{
"message_id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"user_id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"user": {
"id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680",
"role": "user",
"created_at": "2020-01-28T22:17:30.83015Z",
"updated_at": "2020-01-28T22:17:31.19435Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/2.jpg",
"name": "Mia Denys"
},
"type": "love",
"score": 1,
"created_at": "2020-01-28T22:17:31.128376Z",
"updated_at": "2020-01-28T22:17:31.128376Z"
}
],
"own_reactions": [],
"reaction_counts": {
"love": 1
},
"reaction_scores": {
"love": 1
},
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null,
"reply_count": 0,
"created_at": "2020-01-28T22:17:31.107978Z",
"updated_at": "2020-01-28T22:17:31.130506Z",
"mentioned_users": []
}''';
test('should parse json correctly', () {
final message = Message.fromJson(json.decode(jsonExample));
final message = Message.fromJson(jsonFixture('message.json'));
expect(message.id, '4637f7e4-a06b-42db-ba5a-8d8270dd926f');
expect(message.text,
'https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA');
@@ -128,37 +61,7 @@ void main() {
expect(
message.toJson(),
json.decode('''
{
"id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"silent": false,
"attachments": [
{
"type": "video",
"title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"title": "The Lion King Disney GIF - Find & Share on GIPHY",
"thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"text": "Discover & share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.",
"og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
"image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"author_name": "GIPHY",
"asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4",
"actions": []
}
],
"mentioned_users": [],
"parent_id": "parentId",
"quoted_message": null,
"quoted_message_id": null,
"pinned": false,
"pinned_at": null,
"pin_expires": null,
"pinned_by": null,
"show_in_channel": true,
"hey": "test"
}
'''),
jsonFixture('message_to_json.json'),
);
});
});
@@ -0,0 +1,17 @@
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:stream_chat/src/core/models/mute.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/mute', () {
test('should parse json correctly', () {
final mute = Mute.fromJson(jsonFixture('mute.json'));
expect(mute.channel, isA<ChannelModel>());
expect(mute.user, isA<User>());
expect(mute.createdAt, DateTime.parse('2020-12-04T10:39:06.512021Z'));
});
});
}
@@ -0,0 +1,45 @@
import 'package:stream_chat/src/core/models/own_user.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/own_user', () {
test('should parse json correctly', () {
final ownUser = OwnUser.fromJson(jsonFixture('own_user.json'));
expect(ownUser.id, 'super-band-9');
expect(ownUser.role, 'user');
expect(ownUser.createdAt, DateTime.parse('2020-03-03T16:48:28.853674Z'));
expect(ownUser.updatedAt, DateTime.parse('2021-05-26T03:22:20.296181Z'));
expect(
ownUser.lastActive, DateTime.parse('2021-06-16T11:59:59.003453014Z'));
expect(ownUser.banned, false);
expect(ownUser.online, true);
expect(ownUser.devices.length, 1);
expect(ownUser.mutes.length, 0);
expect(ownUser.channelMutes.length, 1);
expect(ownUser.totalUnreadCount, 0);
expect(ownUser.unreadChannels, 0);
expect(ownUser.extraData['image'], 'https://placehold.jp/150x150.png');
expect(ownUser.extraData['name'], 'Proud darkness');
expect(ownUser.extraData['username'], 'Rioland');
});
test('should initialize a OwnUser from a User correctly', () {
final user = User.fromJson(jsonFixture('user.json'));
final ownUser = OwnUser.fromUser(user);
expect(ownUser.id, user.id);
expect(ownUser.id, user.id);
expect(ownUser.role, user.role);
expect(ownUser.createdAt, user.createdAt);
expect(ownUser.updatedAt, user.updatedAt);
expect(ownUser.lastActive, user.lastActive);
expect(ownUser.online, user.online);
expect(ownUser.banned, user.banned);
expect(ownUser.extraData, user.extraData);
});
});
}
@@ -1,34 +1,13 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/reaction.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/reaction', () {
const jsonExample = '''
{
"message_id": "76cd8c82-b557-4e48-9d12-87995d3a0e04",
"user_id": "2de0297c-f3f2-489d-b930-ef77342edccf",
"user": {
"id": "2de0297c-f3f2-489d-b930-ef77342edccf",
"role": "user",
"created_at": "2020-01-28T22:17:30.810011Z",
"updated_at": "2020-01-28T22:17:31.077195Z",
"banned": false,
"online": false,
"image": "https://randomuser.me/api/portraits/women/45.jpg",
"name": "Daisy Morgan"
},
"type": "wow",
"score": 1,
"created_at": "2020-01-28T22:17:31.108742Z",
"updated_at": "2020-01-28T22:17:31.108742Z"
}
''';
test('should parse json correctly', () {
final reaction = Reaction.fromJson(json.decode(jsonExample));
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
expect(reaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04');
expect(reaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z'));
expect(reaction.type, 'wow');
@@ -68,5 +47,72 @@ void main() {
},
);
});
test('copyWith', () {
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
var newReaction = reaction.copyWith();
expect(newReaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04');
expect(
newReaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z'));
expect(newReaction.type, 'wow');
expect(
newReaction.user?.toJson(),
User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan',
}).toJson(),
);
expect(newReaction.score, 1);
expect(newReaction.userId, '2de0297c-f3f2-489d-b930-ef77342edccf');
expect(
newReaction.extraData, {'updated_at': '2020-01-28T22:17:31.108742Z'});
newReaction = reaction.copyWith(
type: 'lol',
createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'),
extraData: {},
messageId: 'test',
score: 2,
user: User(id: 'test'),
userId: 'test',
);
expect(newReaction.type, 'lol');
expect(
newReaction.createdAt,
DateTime.parse('2021-01-28T22:17:31.108742Z'),
);
expect(newReaction.extraData, {});
expect(newReaction.messageId, 'test');
expect(newReaction.score, 2);
expect(newReaction.user, User(id: 'test'));
expect(newReaction.userId, 'test');
});
test('merge', () {
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
final newReaction = reaction.merge(
Reaction(
type: 'lol',
createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'),
extraData: {},
messageId: 'test',
score: 2,
user: User(id: 'test'),
userId: 'test',
),
);
expect(newReaction.type, 'lol');
expect(
newReaction.createdAt,
DateTime.parse('2021-01-28T22:17:31.108742Z'),
);
expect(newReaction.extraData, {});
expect(newReaction.messageId, 'test');
expect(newReaction.score, 2);
expect(newReaction.user, User(id: 'test'));
expect(newReaction.userId, 'test');
});
});
}
@@ -1,23 +1,13 @@
import 'dart:convert';
import 'package:test/test.dart';
import 'package:stream_chat/src/core/models/read.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/read', () {
const jsonExample = '''
{
"user": {
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e"
},
"last_read": "2020-01-28T22:17:30.966485504Z",
"unread_messages": 10
}
''';
test('should parse json correctly', () {
final read = Read.fromJson(json.decode(jsonExample));
final read = Read.fromJson(jsonFixture('read.json'));
expect(read.lastRead, DateTime.parse('2020-01-28T22:17:30.966485504Z'));
expect(read.user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e');
expect(read.unreadMessages, 10);
@@ -36,5 +26,29 @@ void main() {
'unread_messages': 10,
});
});
test('copyWith', () {
final read = Read.fromJson(jsonFixture('read.json'));
var newRead = read.copyWith();
expect(
newRead.lastRead,
DateTime.parse('2020-01-28T22:17:30.966485504Z'),
);
expect(newRead.user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e');
expect(newRead.unreadMessages, 10);
newRead = read.copyWith(
user: User(id: 'test'),
lastRead: DateTime.parse('2021-01-28T22:17:30.966485504Z'),
unreadMessages: 2,
);
expect(
newRead.lastRead,
DateTime.parse('2021-01-28T22:17:30.966485504Z'),
);
expect(newRead.user.id, 'test');
expect(newRead.unreadMessages, 2);
});
});
}
@@ -1,20 +1,14 @@
import 'dart:convert';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:test/test.dart';
import '../../utils.dart';
void main() {
group('src/models/user', () {
const jsonExample = '''
{
"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e",
"role": "test-role"
}
''';
test('should parse json correctly', () {
final user = User.fromJson(json.decode(jsonExample));
final user = User.fromJson(jsonFixture('user.json'));
expect(user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e');
expect(user.name, 'John');
});
test('should serialize to json correctly', () {
@@ -27,5 +21,26 @@ void main() {
'id': 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e',
});
});
test('copyWith', () {
final user = User.fromJson(jsonFixture('user.json'));
var newUser = user.copyWith();
expect(newUser.id, user.id);
expect(newUser.role, user.role);
expect(newUser.name, user.name);
newUser = user.copyWith(
id: 'test',
role: 'test',
extraData: {
'name': 'test',
},
);
expect(newUser.id, 'test');
expect(newUser.role, 'test');
expect(newUser.name, 'test');
});
});
}
+8
View File
@@ -1,10 +1,18 @@
import 'dart:convert';
import 'dart:io';
String fixture(String name) {
final dir = currentDirectory.path;
return File('$dir/test/fixtures/$name').readAsStringSync();
}
File assetFile(String name) {
final dir = currentDirectory.path;
return File('$dir/test/assets/$name');
}
Map<String, dynamic> jsonFixture(String name) => json.decode(fixture(name));
// https://github.com/flutter/flutter/issues/20907
Directory get currentDirectory {
var directory = Directory.current;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

@@ -3550,7 +3550,7 @@ class UsersCompanion extends UpdateCompanion<UserEntity> {
this.online = const Value.absent(),
this.banned = const Value.absent(),
required Map<String, Object?> extraData,
}) : id = Value(id),
}) : id = Value(id),
extraData = Value(extraData);
static Insertable<UserEntity> custom({
Expression<String>? id,
@@ -4723,7 +4723,7 @@ class ChannelQueriesCompanion extends UpdateCompanion<ChannelQueryEntity> {
ChannelQueriesCompanion.insert({
required String queryHash,
required String channelCid,
}) : queryHash = Value(queryHash),
}) : queryHash = Value(queryHash),
channelCid = Value(channelCid);
static Insertable<ChannelQueryEntity> custom({
Expression<String>? queryHash,