@@ -45,7 +45,6 @@ const COLLECTION = 'accounts'
4545 * @property {String } tOTPKey One Time Password Secret Key
4646 * @property {Number } tOTPPeriod One Time Password Key Length (Time) - Default 30 Seconds
4747 * @property {String } accessToken API Access Token
48- * @property {Array } iOSDeviceTokens Array of String based device Ids for Apple iOS devices. *push notifications*
4948 * @property {Object } preferences Object to hold user preferences
5049 * @property {Boolean } preferences.autoRefreshTicketGrid Enable the auto refresh of the ticket grid.
5150 * @property {Boolean } deleted Account Deleted
@@ -190,38 +189,6 @@ userSchema.methods.removeL2Auth = function (callback) {
190189 } )
191190}
192191
193- userSchema . methods . addDeviceToken = function ( token , type , callback ) {
194- if ( _ . isUndefined ( token ) ) return callback ( 'Invalid token' )
195- var user = this
196- // type 1 = iOS
197- // type 2 = Android
198- if ( type === 1 ) {
199- if ( hasDeviceToken ( user , token , type ) ) return callback ( null , token )
200-
201- user . iOSDeviceTokens . push ( token )
202- user . save ( function ( err ) {
203- if ( err ) return callback ( err , null )
204-
205- callback ( null , token )
206- } )
207- }
208- }
209-
210- userSchema . methods . removeDeviceToken = function ( token , type , callback ) {
211- var user = this
212- if ( type === 1 ) {
213- if ( ! hasDeviceToken ( user , token , type ) ) return callback ( )
214-
215- winston . debug ( 'Removing Device: ' + token )
216- user . iOSDeviceTokens . splice ( _ . indexOf ( this . iOSDeviceTokens , token ) , 1 )
217- user . save ( function ( err , u ) {
218- if ( err ) return callback ( err , null )
219-
220- return callback ( null , u . iOSDeviceTokens )
221- } )
222- }
223- }
224-
225192userSchema . methods . addOpenChatWindow = function ( convoId , callback ) {
226193 if ( convoId === undefined ) {
227194 if ( ! _ . isFunction ( callback ) ) return false
@@ -731,35 +698,4 @@ userSchema.statics.getAdmins = function (obj, callback) {
731698 } )
732699}
733700
734- /**
735- * Checks if a user has device token already
736- *
737- * @memberof User
738- * @instance
739- * @method hasDeviceToken
740- *
741- * @param {User } user User to check against
742- * @param {String } token token to check for in given user
743- * @param {Number } type Type of Device token to check.
744- * @return {Boolean }
745- * @example
746- * type:
747- * 1: iOS
748- * 2: Android
749- * 3: Windows
750- */
751- function hasDeviceToken ( user , token , type ) {
752- if ( type === 1 ) {
753- var matches = _ . filter ( user . iOSDeviceTokens , function ( value ) {
754- if ( value === token ) {
755- return value
756- }
757- } )
758-
759- return matches . length > 0
760- }
761-
762- return false
763- }
764-
765701module . exports = mongoose . model ( COLLECTION , userSchema )
0 commit comments