Added community and user views
This commit is contained in:
parent
8f0a2b14b7
commit
63fed075ed
|
@ -0,0 +1,78 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'community.g.dart';
|
||||
|
||||
/// based on https://github.com/LemmyNet/lemmy/blob/464ea862b10fa7b226b2550268e40d8e685a939c/server/lemmy_db/src/community_view.rs#L130
|
||||
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
|
||||
class CommunityView {
|
||||
final int id;
|
||||
final String name;
|
||||
final String title;
|
||||
/// can be null
|
||||
final String icon;
|
||||
/// can be null
|
||||
final String banner;
|
||||
/// can be null
|
||||
final String description;
|
||||
final int categoryId;
|
||||
final int creatorId;
|
||||
final bool removed;
|
||||
final DateTime published;
|
||||
/// can be null
|
||||
final DateTime updated;
|
||||
final bool deleted;
|
||||
final bool nsfw;
|
||||
final String actorId;
|
||||
final bool local;
|
||||
final DateTime lastRefreshedAt;
|
||||
final String creatorActorId;
|
||||
final bool creatorLocal;
|
||||
final String creatorName;
|
||||
/// can be null
|
||||
final String creatorPreferredUsername;
|
||||
/// can be null
|
||||
final String creatorAvatar;
|
||||
final String categoryName;
|
||||
final int numberOfSubscribers;
|
||||
final int numberOfPosts;
|
||||
final int numberOfComments;
|
||||
final int hotRank;
|
||||
/// can be null
|
||||
final int userId;
|
||||
/// can be null
|
||||
final bool subscribed;
|
||||
|
||||
const CommunityView({
|
||||
this.id,
|
||||
this.name,
|
||||
this.title,
|
||||
this.icon,
|
||||
this.banner,
|
||||
this.description,
|
||||
this.categoryId,
|
||||
this.creatorId,
|
||||
this.removed,
|
||||
this.published,
|
||||
this.updated,
|
||||
this.deleted,
|
||||
this.nsfw,
|
||||
this.actorId,
|
||||
this.local,
|
||||
this.lastRefreshedAt,
|
||||
this.creatorActorId,
|
||||
this.creatorLocal,
|
||||
this.creatorName,
|
||||
this.creatorPreferredUsername,
|
||||
this.creatorAvatar,
|
||||
this.categoryName,
|
||||
this.numberOfSubscribers,
|
||||
this.numberOfPosts,
|
||||
this.numberOfComments,
|
||||
this.hotRank,
|
||||
this.userId,
|
||||
this.subscribed,
|
||||
});
|
||||
|
||||
factory CommunityView.fromJson(Map<String, dynamic> json) =>
|
||||
_$CommunityViewFromJson(json);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'user.g.dart';
|
||||
|
||||
/// based on https://github.com/LemmyNet/lemmy/blob/464ea862b10fa7b226b2550268e40d8e685a939c/server/lemmy_db/src/user_view.rs#L58
|
||||
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
|
||||
class UserView {
|
||||
final int id;
|
||||
final String actorId;
|
||||
final String name;
|
||||
/// can be null
|
||||
final String preferredUsername;
|
||||
/// can be null
|
||||
final String avatar;
|
||||
/// can be null
|
||||
final String banner;
|
||||
/// can be null
|
||||
final String email;
|
||||
/// can be null
|
||||
final String matrixUserId;
|
||||
/// can be null
|
||||
final String bio;
|
||||
final bool local;
|
||||
final bool admin;
|
||||
final bool banned;
|
||||
final bool showAvatars;
|
||||
final bool sendNotificationsToEmail;
|
||||
final DateTime published;
|
||||
final int numberOfPosts;
|
||||
final int postScore;
|
||||
final int numberOfComments;
|
||||
final int commentScore;
|
||||
|
||||
factory UserView.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserViewFromJson(json);
|
||||
}
|
Loading…
Reference in New Issue