Move rocketchat models (#13027)
* Move rocketchat settings to specific package * WIP: Move models from rocketchat-lib to a specific package (server) * Move function from rocketchat:lib to rocketchat:utils to use it in rocketchat:models * Move client models from rocketchat:lib to rocketchat:models * Fix lint * Simplify model files * Fix wrong object assignpull/13114/head
parent
454008524d
commit
c6ef5e7b32
@ -1,6 +0,0 @@ |
||||
RocketChat.models.Avatars = new class extends RocketChat.models._Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('avatars'); |
||||
} |
||||
}; |
@ -1,7 +0,0 @@ |
||||
|
||||
RocketChat.models.Uploads = new class extends RocketChat.models._Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('uploads'); |
||||
} |
||||
}; |
@ -1,6 +0,0 @@ |
||||
RocketChat.models.UserDataFiles = new class extends RocketChat.models._Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('userDataFiles'); |
||||
} |
||||
}; |
@ -0,0 +1,11 @@ |
||||
import { Avatars } from 'meteor/rocketchat:models'; |
||||
import { Base as _Base } from 'meteor/rocketchat:models'; |
||||
import { Uploads } from 'meteor/rocketchat:models'; |
||||
import { UserDataFiles } from 'meteor/rocketchat:models'; |
||||
|
||||
Object.assign(RocketChat.models, { |
||||
_Base, |
||||
Avatars, |
||||
Uploads, |
||||
UserDataFiles, |
||||
}); |
@ -1,31 +1,3 @@ |
||||
RocketChat.getDefaultSubscriptionPref = function _getDefaultSubscriptionPref(userPref) { |
||||
const subscription = {}; |
||||
import { getDefaultSubscriptionPref } from 'meteor/rocketchat:utils'; |
||||
|
||||
const { |
||||
desktopNotifications, |
||||
mobileNotifications, |
||||
emailNotificationMode, |
||||
highlights, |
||||
} = (userPref.settings && userPref.settings.preferences) || {}; |
||||
|
||||
if (Array.isArray(highlights) && highlights.length) { |
||||
subscription.userHighlights = highlights; |
||||
} |
||||
|
||||
if (desktopNotifications && desktopNotifications !== 'default') { |
||||
subscription.desktopNotifications = desktopNotifications; |
||||
subscription.desktopPrefOrigin = 'user'; |
||||
} |
||||
|
||||
if (mobileNotifications && mobileNotifications !== 'default') { |
||||
subscription.mobilePushNotifications = mobileNotifications; |
||||
subscription.mobilePrefOrigin = 'user'; |
||||
} |
||||
|
||||
if (emailNotificationMode && emailNotificationMode !== 'default') { |
||||
subscription.emailNotifications = emailNotificationMode; |
||||
subscription.emailPrefOrigin = 'user'; |
||||
} |
||||
|
||||
return subscription; |
||||
}; |
||||
RocketChat.getDefaultSubscriptionPref = getDefaultSubscriptionPref; |
||||
|
@ -0,0 +1,25 @@ |
||||
import { Avatars } from 'meteor/rocketchat:models'; |
||||
import { Base as _Base } from 'meteor/rocketchat:models'; |
||||
import { ExportOperations } from 'meteor/rocketchat:models'; |
||||
import { Messages } from 'meteor/rocketchat:models'; |
||||
import { Reports } from 'meteor/rocketchat:models'; |
||||
import { Rooms } from 'meteor/rocketchat:models'; |
||||
import { Settings } from 'meteor/rocketchat:models'; |
||||
import { Subscriptions } from 'meteor/rocketchat:models'; |
||||
import { Uploads } from 'meteor/rocketchat:models'; |
||||
import { UserDataFiles } from 'meteor/rocketchat:models'; |
||||
import { Users } from 'meteor/rocketchat:models'; |
||||
|
||||
Object.assign(RocketChat.models, { |
||||
_Base, |
||||
Avatars, |
||||
ExportOperations, |
||||
Messages, |
||||
Reports, |
||||
Rooms, |
||||
Settings, |
||||
Subscriptions, |
||||
Uploads, |
||||
UserDataFiles, |
||||
Users, |
||||
}); |
@ -0,0 +1,11 @@ |
||||
import { Base } from './models/_Base'; |
||||
import Avatars from './models/Avatars'; |
||||
import Uploads from './models/Uploads'; |
||||
import UserDataFiles from './models/UserDataFiles'; |
||||
|
||||
export { |
||||
Base, |
||||
Avatars, |
||||
Uploads, |
||||
UserDataFiles, |
||||
}; |
@ -0,0 +1,10 @@ |
||||
import { Base } from './_Base'; |
||||
|
||||
export class Avatars extends Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('avatars'); |
||||
} |
||||
} |
||||
|
||||
export default new Avatars(); |
@ -0,0 +1,10 @@ |
||||
import { Base } from './_Base'; |
||||
|
||||
export class Uploads extends Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('uploads'); |
||||
} |
||||
} |
||||
|
||||
export default new Uploads(); |
@ -0,0 +1,10 @@ |
||||
import { Base } from './_Base'; |
||||
|
||||
export class UserDataFiles extends Base { |
||||
constructor() { |
||||
super(); |
||||
this._initModel('userDataFiles'); |
||||
} |
||||
} |
||||
|
||||
export default new UserDataFiles(); |
@ -0,0 +1,17 @@ |
||||
Package.describe({ |
||||
name: 'rocketchat:models', |
||||
summary: 'RocketChat Models', |
||||
version: '1.0.0', |
||||
git: '', |
||||
}); |
||||
|
||||
Package.onUse(function(api) { |
||||
api.use([ |
||||
'ecmascript', |
||||
'rocketchat:settings', |
||||
'rocketchat:utils', |
||||
'konecty:multiple-instances-status', |
||||
]); |
||||
api.mainModule('client/index.js', 'client'); |
||||
api.mainModule('server/index.js', 'server'); |
||||
}); |
@ -0,0 +1,27 @@ |
||||
import { Base } from './models/_Base'; |
||||
import { BaseDb } from './models/_BaseDb'; |
||||
import Avatars from './models/Avatars'; |
||||
import ExportOperations from './models/ExportOperations'; |
||||
import Messages from './models/Messages'; |
||||
import Reports from './models/Reports'; |
||||
import Rooms from './models/Rooms'; |
||||
import Settings from './models/Settings'; |
||||
import Subscriptions from './models/Subscriptions'; |
||||
import Uploads from './models/Uploads'; |
||||
import UserDataFiles from './models/UserDataFiles'; |
||||
import Users from './models/Users'; |
||||
|
||||
export { |
||||
Base, |
||||
BaseDb, |
||||
Avatars, |
||||
ExportOperations, |
||||
Messages, |
||||
Reports, |
||||
Rooms, |
||||
Settings, |
||||
Subscriptions, |
||||
Uploads, |
||||
UserDataFiles, |
||||
Users, |
||||
}; |
@ -1,9 +1,11 @@ |
||||
import { t, isRtl } from '../lib/tapi18n'; |
||||
import { isChrome, isFirefox } from './lib/browsers'; |
||||
import { getDefaultSubscriptionPref } from '../lib/getDefaultSubscriptionPref'; |
||||
|
||||
export { |
||||
t, |
||||
isRtl, |
||||
isChrome, |
||||
isFirefox, |
||||
getDefaultSubscriptionPref, |
||||
}; |
||||
|
@ -0,0 +1,31 @@ |
||||
export const getDefaultSubscriptionPref = (userPref) => { |
||||
const subscription = {}; |
||||
|
||||
const { |
||||
desktopNotifications, |
||||
mobileNotifications, |
||||
emailNotificationMode, |
||||
highlights, |
||||
} = (userPref.settings && userPref.settings.preferences) || {}; |
||||
|
||||
if (Array.isArray(highlights) && highlights.length) { |
||||
subscription.userHighlights = highlights; |
||||
} |
||||
|
||||
if (desktopNotifications && desktopNotifications !== 'default') { |
||||
subscription.desktopNotifications = desktopNotifications; |
||||
subscription.desktopPrefOrigin = 'user'; |
||||
} |
||||
|
||||
if (mobileNotifications && mobileNotifications !== 'default') { |
||||
subscription.mobilePushNotifications = mobileNotifications; |
||||
subscription.mobilePrefOrigin = 'user'; |
||||
} |
||||
|
||||
if (emailNotificationMode && emailNotificationMode !== 'default') { |
||||
subscription.emailNotifications = emailNotificationMode; |
||||
subscription.emailPrefOrigin = 'user'; |
||||
} |
||||
|
||||
return subscription; |
||||
}; |
@ -1,6 +1,8 @@ |
||||
import { t, isRtl } from '../lib/tapi18n'; |
||||
import { getDefaultSubscriptionPref } from '../lib/getDefaultSubscriptionPref'; |
||||
|
||||
export { |
||||
t, |
||||
isRtl, |
||||
getDefaultSubscriptionPref, |
||||
}; |
||||
|
Loading…
Reference in new issue