forked from Ivasoft/mattermost-mobile
MM_30476 [v2] Section 'Post' of the server schema (#5077)
* MM_30476 : Added all isolated tables from the server schema * MM_30476 : Updated 'test' script in package.json * MM_30476 : ADDED team section of the server schema * MM_30476 : ADDED section for Group from the server schema * MM_30476 : One PR for one section only * MM_30476 : One PR for one section only * MM_30476 : Rename table schemas to avoid name collision * MM_30476 : ADDED section 'Post' of the server schema * MM_30476 : Updated Post section of the server schema * MM_30476 : Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * MM_30476 : Corrected draft wrt to suggestions * MM_30476 : Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * MM_30476 : ADDED lazy queries to group_membership model * MM_30476 : Update model to match definition - GroupsInChannel * MM_30476 : Removed groups_in_team definition from Post section of this PR * MM_30476 : Updated all comments to match their variable/field name * MM_30476 : Updated test * MM_30476 : Updated imports and groups_in_team definition * MM_30476 : Updated FileInfo * MM_30476 : Updated Posts and PostMetadata ts types Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
27
types/database/draft.d.ts
vendored
Normal file
27
types/database/draft.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
/**
|
||||
* The Draft model represents the draft state of messages in Direct/Group messages and in channels
|
||||
*/
|
||||
export default class Draft extends Model {
|
||||
/** table (entity name) : Draft */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key pointing to the channel in which the draft was made */
|
||||
channelId: string;
|
||||
|
||||
/** message : The draft message */
|
||||
message: string;
|
||||
|
||||
/** root_id : The root_id will be empty most of the time unless the draft relates to a draft reply of a thread */
|
||||
rootId: string;
|
||||
|
||||
/** files : The files field will hold an array of files object that have not yet been uploaded and persisted within the FILE entity */
|
||||
files: FileInfo[];
|
||||
}
|
||||
48
types/database/file.d.ts
vendored
Normal file
48
types/database/file.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import Post from '@typings/database/post';
|
||||
|
||||
/**
|
||||
* The File model works in pair with the Post model. It hosts information about the files shared in a Post
|
||||
*/
|
||||
export default class File extends Model {
|
||||
/** table (entity name) : File */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** extension : The file's extension */
|
||||
extension: string;
|
||||
|
||||
/** height : The height for the image */
|
||||
height: number;
|
||||
|
||||
/** image_thumbnail : A base64 representation of an image */
|
||||
imageThumbnail: string;
|
||||
|
||||
/** local_path : Local path of the file that has been uploaded to server */
|
||||
localPath: string;
|
||||
|
||||
/** mime_type : The media type */
|
||||
mimeType: string;
|
||||
|
||||
/** name : The name for the file object */
|
||||
name: string;
|
||||
|
||||
/** post_id : The foreign key of the related Post model */
|
||||
postId: string;
|
||||
|
||||
/** size : The numeric value of the size for the file */
|
||||
size: number;
|
||||
|
||||
/** width : The width of the file object/image */
|
||||
width: number;
|
||||
|
||||
/** post : The related Post record for this file */
|
||||
post: Relation<Post>;
|
||||
}
|
||||
80
types/database/index.d.ts
vendored
80
types/database/index.d.ts
vendored
@@ -11,13 +11,87 @@ interface NotifyProps {
|
||||
push: string;
|
||||
}
|
||||
|
||||
interface UserProps {
|
||||
[userPropsName : string] : any
|
||||
interface UserProps {
|
||||
[userPropsName: string]: any
|
||||
}
|
||||
|
||||
interface Timezone {
|
||||
interface Timezone {
|
||||
automaticTimezone: string
|
||||
manualTimezone: string,
|
||||
useAutomaticTimezone: true,
|
||||
}
|
||||
|
||||
interface PostEmbed {
|
||||
type: PostEmbedType;
|
||||
url: string;
|
||||
data: Record<string, any>;
|
||||
}
|
||||
|
||||
interface CustomEmoji {
|
||||
id: string;
|
||||
create_at: number;
|
||||
update_at: number;
|
||||
delete_at: number;
|
||||
creator_id: string;
|
||||
name: string;
|
||||
category: 'custom';
|
||||
}
|
||||
|
||||
interface FileInfo {
|
||||
id: string;
|
||||
user_id: string;
|
||||
post_id: string;
|
||||
create_at: number;
|
||||
update_at: number;
|
||||
delete_at: number;
|
||||
name: string;
|
||||
extension: string;
|
||||
size: number;
|
||||
mime_type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
has_preview_image: boolean;
|
||||
clientId: string;
|
||||
localPath?: string;
|
||||
uri?: string;
|
||||
loading?: boolean;
|
||||
}
|
||||
|
||||
type PostEmbedType = 'image' | 'message_attachment' | 'opengraph';
|
||||
|
||||
interface PostImage {
|
||||
height: number;
|
||||
width: number;
|
||||
format?: string;
|
||||
frame_count?: number;
|
||||
}
|
||||
|
||||
interface Reaction {
|
||||
user_id: string;
|
||||
post_id: string;
|
||||
emoji_name: string;
|
||||
create_at: number;
|
||||
}
|
||||
|
||||
interface PostMetadataTypes {
|
||||
embeds: Array<PostEmbed>;
|
||||
emojis: Array<CustomEmoji>;
|
||||
files: Array<FileInfo>;
|
||||
images: Dictionary<PostImage>;
|
||||
reactions: Array<Reaction>;
|
||||
}
|
||||
|
||||
type PostType = 'system_add_remove' |
|
||||
'system_add_to_channel' |
|
||||
'system_add_to_team' |
|
||||
'system_channel_deleted' |
|
||||
'system_channel_restored' |
|
||||
'system_displayname_change' |
|
||||
'system_convert_channel' |
|
||||
'system_ephemeral' |
|
||||
'system_header_change' |
|
||||
'system_join_channel' |
|
||||
'system_join_leave' |
|
||||
'system_leave_channel' |
|
||||
'system_purpose_change' |
|
||||
'system_remove_from_channel';
|
||||
|
||||
76
types/database/post.d.ts
vendored
76
types/database/post.d.ts
vendored
@@ -1,10 +1,84 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import Model from '@nozbe/watermelondb/Model';
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import Channel from '@typings/database/channel';
|
||||
import Draft from '@typings/database/draft';
|
||||
import File from '@typings/database/file';
|
||||
import PostInThread from '@typings/database/posts_in_thread';
|
||||
import PostMetadata from '@typings/database/post_metadata';
|
||||
import Reaction from '@typings/database/reaction';
|
||||
import User from '@typings/database/user';
|
||||
|
||||
/**
|
||||
* The Post model is the building block of communication in the Mattermost app.
|
||||
*/
|
||||
export default class Post extends Model {
|
||||
/** table (entity name) : Post */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key for the Channel to which this post belongs to. */
|
||||
channelId: string;
|
||||
|
||||
/** create_at : The timestamp to when this post was first created */
|
||||
createAt: number;
|
||||
|
||||
/** delete_at : The timestamp to when this post was last archived/deleted */
|
||||
deleteAt: number;
|
||||
|
||||
/** edit_at : The timestamp to when this post was last edited */
|
||||
editAt: number;
|
||||
|
||||
/** is_pinned : A Boolean flag indicating if this Post is pinned */
|
||||
isPinned: boolean;
|
||||
|
||||
/** message : Message in the post */
|
||||
message: string;
|
||||
|
||||
/** original_id : Any post will have this value empty unless it is updated */
|
||||
originalId: string;
|
||||
|
||||
/** pending_post_id : The id given to a post before it is published on the server */
|
||||
pendingPostId: string;
|
||||
|
||||
/** previous_post_id : Id of the previous post. If this value is empty, this implies that it is not in the db and we will request it from server */
|
||||
previousPostId: string;
|
||||
|
||||
/** root_id : Used in threads. All posts under a thread will have this id in common */
|
||||
rootId: string;
|
||||
|
||||
/** type : Type of props (e.g. system message) */
|
||||
type: string;
|
||||
|
||||
/** user_id : The foreign key of the User who authored this post. */
|
||||
userId: string;
|
||||
|
||||
/** props : Additional attributes for this props */
|
||||
props: string;
|
||||
|
||||
/** drafts : Every drafts associated with this Post */
|
||||
drafts: Draft;
|
||||
|
||||
/** files: All the files associated with this Post */
|
||||
files: File[];
|
||||
|
||||
/** postsInThread: Every posts associated to a thread */
|
||||
postsInThread: PostInThread[];
|
||||
|
||||
/** metadata: All the extra data associated with this Post */
|
||||
metadata: PostMetadata[];
|
||||
|
||||
/** reactions: All the reactions associated with this Post */
|
||||
reactions: Reaction[];
|
||||
|
||||
/** author: The author of this Post */
|
||||
author: Relation<User>;
|
||||
|
||||
/** channel: The channel which is presenting this Post */
|
||||
channel: Relation<Channel>;
|
||||
}
|
||||
|
||||
30
types/database/post_metadata.d.ts
vendored
Normal file
30
types/database/post_metadata.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import Post from '@typings/database/post';
|
||||
|
||||
/**
|
||||
* PostMetadata provides additional information on a POST
|
||||
*/
|
||||
export default class PostMetadata extends Model {
|
||||
/** table (entity name) : PostMetadata */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** post_id : The foreign key of the parent POST model */
|
||||
postId: string;
|
||||
|
||||
/** type : The type will work in tandem with the value present in the field 'data'. One 'type' for each kind of 'data' */
|
||||
type: string;
|
||||
|
||||
/** data : Different types of data ranging from arrays, emojis, files to images and reactions. */
|
||||
data: string;
|
||||
|
||||
/** post: The record representing the POST parent. */
|
||||
post: Relation<Post>;
|
||||
}
|
||||
21
types/database/posts_in_channel.d.ts
vendored
21
types/database/posts_in_channel.d.ts
vendored
@@ -1,12 +1,31 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import Model from '@nozbe/watermelondb/Model';
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import Channel from '@typings/database/channel';
|
||||
|
||||
/**
|
||||
* PostsInChannel model helps us to combine adjacent posts together without leaving
|
||||
* gaps in between for an efficient user reading experience of posts.
|
||||
*/
|
||||
export default class PostsInChannel extends Model {
|
||||
/** table (entity name) : PostsInChannel */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key of the related parent channel */
|
||||
channelId: string;
|
||||
|
||||
/** earliest : The earliest timestamp of the post in that channel */
|
||||
earliest: number;
|
||||
|
||||
/** latest : The latest timestamp of the post in that channel */
|
||||
latest: number;
|
||||
|
||||
/** channel : The parent record of the channel for those posts */
|
||||
channel: Relation<Channel>;
|
||||
}
|
||||
|
||||
31
types/database/posts_in_thread.d.ts
vendored
Normal file
31
types/database/posts_in_thread.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import Post from '@typings/database/post';
|
||||
|
||||
/**
|
||||
* PostsInThread model helps us to combine adjacent threads together without leaving
|
||||
* gaps in between for an efficient user reading experience for threads.
|
||||
*/
|
||||
export default class PostsInThread extends Model {
|
||||
/** table (entity name) : PostsInThread */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** earliest : Lower bound of a timestamp range */
|
||||
earliest: number;
|
||||
|
||||
/** latest : Upper bound of a timestamp range */
|
||||
latest: number;
|
||||
|
||||
/** post_id : The foreign key of the related Post model */
|
||||
postId: string;
|
||||
|
||||
/** post : The related record to the parent Post model */
|
||||
post: Relation<Post>;
|
||||
}
|
||||
Reference in New Issue
Block a user