-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6: migrated "user" #1138
Merged
ES6: migrated "user" #1138
Changes from 29 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
acb9357
ConnectionStatus.js
bennycode b197602
UserConnectionMapper
bennycode a8e2ed7
z.user.UserError
bennycode c0f8db9
append_random_digits
bennycode 4c943f0
expect length 12
bennycode a8ad343
Added test case
bennycode c780028
Extended suggestions check
bennycode d2423e4
Merge branch 'dev' into es6-user
bennycode 08b419d
UserService
bennycode a5c1136
Merge branch 'dev' into es6-user
bennycode a7c3b38
Started working on UserMapper...
bennycode 0f2fd2d
UserMapper
bennycode c825bc5
UserMapper
bennycode 780ed21
Merged with dev
bennycode 849ac04
Updated JSDoc
bennycode 46251e4
Added missing semicolon
bennycode 121d349
Fixing tests
bennycode 4cfc3de
Working on UserRepository
bennycode 60fd5c3
UserRepository.js
bennycode d4b4832
Down to 2 errors
bennycode 7b7831f
1 error left...
bennycode b0bf840
Fixed tests
bennycode e9d0c7f
JSDoc
bennycode 8f1c030
Finished with JSDoc
bennycode 6fe345b
Merge branch 'dev' into es6-user
bennycode db21512
Merge branch 'dev' into es6-user
bennycode db99c7e
Merge branch 'dev' into es6-user
bennycode febabf9
index
bennycode f974718
Merge branch 'dev' into es6-user
bennycode 4a0ea08
Fixed handle generation
bennycode 221cf79
Removed mapping
bennycode 98805f2
[ci skip]
bennycode 7d6a130
review
bennycode d4d8da2
Removed logger return statements
bennycode f5fc8df
IDs
bennycode 9cf58cb
Merge branch 'dev' into es6-user
bennycode a6033fb
Merge branch 'dev' into es6-user
bennycode ebeaa3e
Fixed props
bennycode b433cc1
Merge branch 'dev' into es6-user
bennycode a26b2b1
Merge branch 'dev' into es6-user
bennycode ebd3f63
Merge branch 'dev' into es6-user
bennycode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2017 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
window.z = window.z || {}; | ||
window.z.user = z.user || {}; | ||
|
||
z.user.ConnectionStatus = { | ||
ACCEPTED: 'accepted', | ||
BLOCKED: 'blocked', | ||
CANCELLED: 'cancelled', | ||
IGNORED: 'ignored', | ||
PENDING: 'pending', | ||
SENT: 'sent', | ||
UNKNOWN: '', | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2017 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
window.z = window.z || {}; | ||
window.z.user = z.user || {}; | ||
|
||
/** | ||
* Connection mapper to convert all server side JSON connections into core connection entities. | ||
* @class z.user.UserConnectionMapper | ||
*/ | ||
z.user.UserConnectionMapper = class UserConnectionMapper { | ||
// Construct a new user mapper. | ||
constructor() { | ||
this.logger = new z.util.Logger('z.user.UserConnectionMapper', z.config.LOGGER.OPTIONS); | ||
|
||
/** | ||
* Converts JSON connection into connection entity. | ||
* @param {JSON} data - Connection data | ||
* @returns {z.entity.Connection} Mapped connection entity | ||
*/ | ||
this.map_user_connection_from_json = function(data) { | ||
const connection_et = new z.entity.Connection(); | ||
return this.update_user_connection_from_json(connection_et, data); | ||
}; | ||
|
||
/** | ||
* Convert multiple JSON connections into connection entities. | ||
* @param {Object} data - Connection data | ||
* @returns {Array<z.entity.Connection>} Mapped connection entities | ||
*/ | ||
this.map_user_connections_from_json = function(data) { | ||
return data | ||
.filter((connection) => connection !== undefined) | ||
.map((connection) => this.map_user_connection_from_json(connection)); | ||
}; | ||
|
||
/** | ||
* Maps JSON connection into a blank connection entity or updates an existing one. | ||
* @param {z.entity.Connection} connection_et - Connection entity that the info shall be mapped to | ||
* @param {JSON} data - Connection data | ||
* @returns {z.entity.Connection} Mapped connection entity | ||
*/ | ||
this.update_user_connection_from_json = function(connection_et, data) { | ||
connection_et.status(data.status); | ||
connection_et.conversation_id = data.conversation; | ||
connection_et.to = data.to; | ||
connection_et.from = data.from; | ||
connection_et.last_update = data.last_update; | ||
connection_et.message = data.message; | ||
return connection_et; | ||
}; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2017 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
window.z = window.z || {}; | ||
window.z.user = z.user || {}; | ||
|
||
z.user.UserError = class UserError extends Error { | ||
constructor(type) { | ||
super(); | ||
|
||
this.name = this.constructor.name; | ||
this.stack = (new Error()).stack; | ||
this.type = type || z.user.UserError.TYPE.UNKNOWN; | ||
|
||
switch (this.type) { | ||
case z.user.UserError.TYPE.PRE_KEY_NOT_FOUND: | ||
this.message = 'Pre-key not found'; | ||
break; | ||
case z.user.UserError.TYPE.REQUEST_FAILURE: | ||
this.message = 'User related backend request failure'; | ||
break; | ||
case z.user.UserError.TYPE.USER_NOT_FOUND: | ||
this.message = 'User not found'; | ||
break; | ||
case z.user.UserError.TYPE.USERNAME_TAKEN: | ||
this.message = 'Username is already taken'; | ||
break; | ||
default: | ||
this.message = 'Unknown UserError'; | ||
break; | ||
} | ||
} | ||
|
||
static get TYPE() { | ||
return { | ||
PRE_KEY_NOT_FOUND: 'z.user.UserError.TYPE.PRE_KEY_NOT_FOUND', | ||
REQUEST_FAILURE: 'z.user.UserError.TYPE.REQUEST_FAILURE', | ||
UNKNOWN: 'z.user.UserError.TYPE.UNKNOWN', | ||
USER_NOT_FOUND: 'z.user.UserError.TYPE.USER_NOT_FOUND', | ||
USERNAME_TAKEN: 'z.user.UserError.TYPE.USERNAME_TAKEN', | ||
}; | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No nead to break on default