forked from Ivasoft/mattermost-mobile
* Added DrawerItem component
* WIP Account Screen
* Added react-native-paper
* Added StatusLabel Component
* Extracted i18n
* TS fix DrawerItem component
* WIP Account Screen
* Added server name label under log out
* Updated translation
* WIP
* Fixes the Offline text style
* Added Metropolis fonts
* WIP
* Typo clean up
* WIP
* WIP
* WIP
* Added server display name
* Writing OpenSans properly
* WIP
* WIP
* Added OptionsModal
* Opening OptionsModal
* Added translation keys
* Writes status to local db
* Fix missing translation
* Fix OptionModal not dismissing
* Pushing status to server
* Refactored
* Added CustomStatusExpiry component
* Added sub components
* Added CustomLabel
* CustomStatus WIP
* Added Custom Status screen WIP
* WIP - unsetCustomStatus and CustomStatus constant
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* WIP
* Retrieving RecentCustomStatuses from Preferences table
* WIP
* WIP
* WIP
* Added Clear After Modal
* WIP - Transations
* WIP
* Done with showing modal cst
* wip
* Clear After Modal - DONE
* fix
* Added missing API calls
* wip
* Causing screen refresh
* wip
* WIP
* WIP
* WIP
* Code clean up
* Added OOO alert box
* Refactored Options-Item
* Refactored OptionsModalList component
* Opening 'status' in BottomSheet instead of OptionsModal
* AddReaction screen - WIP
* Add Reaction screen - WIP
* Added EmojiPickerRow
* Added @components/emoji_picker - WIP
* Emoji Picker - WIP
* WIP
* WIP
* WIP
* SectionList - WIP
* Installed react-native-section_list_get_item_layout
* Adding API calls - WIP
* WIP
* Search Bar component - WIP
* WIP
* WIP
* WIP
* Rendering Emoticons now - have to tackle some fixmes
* Code clean up
* Code clean up - WIP
* Code clean up
* WIP
* Major clean up
* wip
* WIP
* Fix rendering issue with SectionIcons and SearchBar
* Tackled the CustomEmojiPage
* Code clean up
* WIP
* Done with loading User Profiles for Custom Emoji
* Code clean up
* Code Clean up
* Fix screen Account
* Added missing sql file for IOS Pod
* Updated Podfile.lock
* Using queryConfig instead of queryCommonSystemValues
* Fix - Custom status
* Fix - Custom Status - Error
* Fix - Clear Pass Status - WIP
* Fix - Custom Status Clear
* Need to fix CST clear
* WIP
* Status clear - working
* Using catchError operator
* remove unnecessary prop
* Status BottomSheet now has colored indicators
* Added KeyboardTrackingView from 'react-native-keyboard-tracking-view'
* Code clean up
* WIP
* code clean up
* Added a safety check
* Fix - Display suggestions
* Code clean up based on PR Review
* Code clean up
* Code clean up
* Code clean up
* Corrections
* Fix tsc
* TS fix
* Removed unnecessary prop
* Fix SearchBar Ts
* Updated tests
* Delete search_bar.test.js.snap
* Merge branch 'gekidou' into gekidou_account_screen
* Revert "Merge branch 'gekidou' into gekidou_account_screen"
This reverts commit 5defc31321.
* Fix fonts
* Refactor home account screen
* fix theme provider
* refactor bottom sheet
* remove paper provider
* update drawer item snapshots
* Remove options modal screen
* remove react-native-ui-lib dependency
* Refactor & fix custom status & navigation (including tablet)
* Refactor emoji picker
Co-authored-by: Avinash Lingaloo <>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
145 lines
5.6 KiB
TypeScript
145 lines
5.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {children, field, json} from '@nozbe/watermelondb/decorators';
|
|
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
import {safeParseJSON} from '@utils/helpers';
|
|
|
|
import type ChannelModel from '@typings/database/models/servers/channel';
|
|
import type ChannelMembershipModel from '@typings/database/models/servers/channel_membership';
|
|
import type GroupMembershipModel from '@typings/database/models/servers/group_membership';
|
|
import type PostModel from '@typings/database/models/servers/post';
|
|
import type PreferenceModel from '@typings/database/models/servers/preference';
|
|
import type ReactionModel from '@typings/database/models/servers/reaction';
|
|
import type TeamMembershipModel from '@typings/database/models/servers/team_membership';
|
|
|
|
const {
|
|
CHANNEL,
|
|
CHANNEL_MEMBERSHIP,
|
|
GROUP_MEMBERSHIP,
|
|
POST,
|
|
PREFERENCE,
|
|
REACTION,
|
|
TEAM_MEMBERSHIP,
|
|
USER,
|
|
} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* The User model represents the 'USER' table and its relationship to other
|
|
* shareholders in the app.
|
|
*/
|
|
export default class UserModel extends Model {
|
|
/** table (name) : User */
|
|
static table = USER;
|
|
|
|
/** associations : Describes every relationship to this table. */
|
|
static associations: Associations = {
|
|
|
|
/** USER has a 1:N relationship with CHANNEL. A user can create multiple channels */
|
|
[CHANNEL]: {type: 'has_many', foreignKey: 'creator_id'},
|
|
|
|
/** USER has a 1:N relationship with CHANNEL_MEMBERSHIP. A user can be part of multiple channels */
|
|
[CHANNEL_MEMBERSHIP]: {type: 'has_many', foreignKey: 'user_id'},
|
|
|
|
/** USER has a 1:N relationship with GROUP_MEMBERSHIP. A user can be part of multiple groups */
|
|
[GROUP_MEMBERSHIP]: {type: 'has_many', foreignKey: 'user_id'},
|
|
|
|
/** USER has a 1:N relationship with POST. A user can author multiple posts */
|
|
[POST]: {type: 'has_many', foreignKey: 'user_id'},
|
|
|
|
/** USER has a 1:N relationship with PREFERENCE. A user can have multiple preferences */
|
|
[PREFERENCE]: {type: 'has_many', foreignKey: 'user_id'},
|
|
|
|
/** USER has a 1:N relationship with REACTION. A user can react to multiple posts */
|
|
[REACTION]: {type: 'has_many', foreignKey: 'user_id'},
|
|
|
|
/** USER has a 1:N relationship with TEAM_MEMBERSHIP. A user can join multiple teams */
|
|
[TEAM_MEMBERSHIP]: {type: 'has_many', foreignKey: 'user_id'},
|
|
};
|
|
|
|
/** auth_service : The type of authentication service registered to that user */
|
|
@field('auth_service') authService!: string;
|
|
|
|
/** update_at : The timestamp at which this user account has been updated */
|
|
@field('update_at') updateAt!: number;
|
|
|
|
/** delete_at : The timestamp at which this user account has been archived/deleted */
|
|
@field('delete_at') deleteAt!: number;
|
|
|
|
/** email : The email address for that user */
|
|
@field('email') email!: string;
|
|
|
|
/** first_name : The user's first name */
|
|
@field('first_name') firstName!: string;
|
|
|
|
/** is_bot : Boolean flag indicating if the user is a bot */
|
|
@field('is_bot') isBot!: boolean;
|
|
|
|
/** is_guest : Boolean flag indicating if the user is a guest */
|
|
@field('is_guest') isGuest!: boolean;
|
|
|
|
/** last_name : The user's last name */
|
|
@field('last_name') lastName!: string;
|
|
|
|
/** last_picture_update : The timestamp of the last time the profile picture has been updated */
|
|
@field('last_picture_update') lastPictureUpdate!: number;
|
|
|
|
/** locale : The user's locale */
|
|
@field('locale') locale!: string;
|
|
|
|
/** nickname : The user's nickname */
|
|
@field('nickname') nickname!: string;
|
|
|
|
/** position : The user's position in the company */
|
|
@field('position') position!: string;
|
|
|
|
/** roles : The associated roles that this user has. Multiple roles concatenated together with comma to form a single string. */
|
|
@field('roles') roles!: string;
|
|
|
|
/** status : The presence status for the user */
|
|
@field('status') status!: string;
|
|
|
|
/** username : The user's username */
|
|
@field('username') username!: string;
|
|
|
|
/** notify_props : Notification preferences/configurations */
|
|
@json('notify_props', safeParseJSON) notifyProps!: UserNotifyProps | null;
|
|
|
|
/** props : Custom objects ( e.g. custom status) can be stored in there. Its type definition is known as
|
|
* 'excess property check' in Typescript land. We keep using it till we build up the final shape of this object.
|
|
*/
|
|
@json('props', safeParseJSON) props!: UserProps | null;
|
|
|
|
/** timezone : The timezone for this user */
|
|
@json('timezone', safeParseJSON) timezone!: UserTimezone | null;
|
|
|
|
/** channelsCreated : All the channels that this user created */
|
|
@children(CHANNEL) channelsCreated!: ChannelModel[];
|
|
|
|
/** channels : All the channels that this user is part of */
|
|
@children(CHANNEL_MEMBERSHIP) channels!: ChannelMembershipModel[];
|
|
|
|
/** groups : All the groups that this user is part of */
|
|
@children(GROUP_MEMBERSHIP) groups!: GroupMembershipModel[];
|
|
|
|
/** posts : All the posts that this user has written*/
|
|
@children(POST) posts!: PostModel[];
|
|
|
|
/** preferences : All user preferences */
|
|
@children(PREFERENCE) preferences!: PreferenceModel[];
|
|
|
|
/** reactions : All the reactions to posts that this user had */
|
|
@children(REACTION) reactions!: ReactionModel[];
|
|
|
|
/** teams : All the team that this user is part of */
|
|
@children(TEAM_MEMBERSHIP) teams!: TeamMembershipModel[];
|
|
|
|
prepareStatus = (status: string) => {
|
|
this.prepareUpdate((u) => {
|
|
u.status = status;
|
|
});
|
|
}
|
|
}
|