added UserMention and Site views

This commit is contained in:
shilangyu 2020-08-10 12:39:22 +00:00
parent 2af364abeb
commit cf59f9f2ae
2 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
part 'site.g.dart';
/// based on https://github.com/LemmyNet/lemmy/blob/464ea862b10fa7b226b2550268e40d8e685a939c/server/lemmy_db/src/site_view.rs#L31
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
class SiteView {
final int id;
final String name;
/// can be null
final String description;
final int creatorId;
final DateTime published;
/// can be null
final DateTime updated;
final bool enableDownvotes;
final bool openRegistration;
final bool enableNsfw;
/// can be null
final String icon;
/// can be null
final String banner;
final String creatorName;
/// can be null
final String creatorPreferredUsername;
/// can be null
final String creatorAvatar;
final int numberOfUsers;
final int numberOfPosts;
final int numberOfComments;
final int numberOfCommunities;
const SiteView({
this.id,
this.name,
this.description,
this.creatorId,
this.published,
this.updated,
this.enableDownvotes,
this.openRegistration,
this.enableNsfw,
this.icon,
this.banner,
this.creatorName,
this.creatorPreferredUsername,
this.creatorAvatar,
this.numberOfUsers,
this.numberOfPosts,
this.numberOfComments,
this.numberOfCommunities,
});
factory SiteView.fromJson(Map<String, dynamic> json) =>
_$SiteViewFromJson(json);
}

View File

@ -58,6 +58,104 @@ class UserView {
this.numberOfComments, this.numberOfComments,
this.commentScore, this.commentScore,
}); });
factory UserView.fromJson(Map<String, dynamic> json) => factory UserView.fromJson(Map<String, dynamic> json) =>
_$UserViewFromJson(json); _$UserViewFromJson(json);
} }
/// based on https://github.com/LemmyNet/lemmy/blob/464ea862b10fa7b226b2550268e40d8e685a939c/server/lemmy_db/src/user_mention_view.rs#L90
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
class UserMentionView {
final int id;
final int userMentionId;
final int creatorId;
final String creatorActorId;
final bool creatorLocal;
final int postId;
final String postName;
/// can be null
final int parentId;
final String content;
final bool removed;
final bool read;
final DateTime published;
/// can be null
final DateTime updated;
final bool deleted;
final int communityId;
final String communityActorId;
final bool communityLocal;
final String communityName;
/// can be null
final String communityIcon;
final bool banned;
final bool bannedFromCommunity;
final String creatorName;
/// can be null
final String creatorPreferredUsername;
/// can be null
final String creatorAvatar;
final int score;
final int upvotes;
final int downvotes;
final int hotRank;
final int hotRankActive;
/// can be null
final int userId;
/// can be null
final int myVote;
/// can be null
final bool saved;
final int recipientId;
final String recipientActorId;
final bool recipientLocal;
const UserMentionView({
this.id,
this.userMentionId,
this.creatorId,
this.creatorActorId,
this.creatorLocal,
this.postId,
this.postName,
this.parentId,
this.content,
this.removed,
this.read,
this.published,
this.updated,
this.deleted,
this.communityId,
this.communityActorId,
this.communityLocal,
this.communityName,
this.communityIcon,
this.banned,
this.bannedFromCommunity,
this.creatorName,
this.creatorPreferredUsername,
this.creatorAvatar,
this.score,
this.upvotes,
this.downvotes,
this.hotRank,
this.hotRankActive,
this.userId,
this.myVote,
this.saved,
this.recipientId,
this.recipientActorId,
this.recipientLocal,
});
factory UserMentionView.fromJson(Map<String, dynamic> json) =>
_$UserMentionViewFromJson(json);
}