Skip to content
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
merged 41 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
acb9357
ConnectionStatus.js
bennycode Apr 25, 2017
b197602
UserConnectionMapper
bennycode Apr 25, 2017
a8e2ed7
z.user.UserError
bennycode Apr 25, 2017
c0f8db9
append_random_digits
bennycode Apr 25, 2017
4c943f0
expect length 12
bennycode Apr 25, 2017
a8ad343
Added test case
bennycode Apr 25, 2017
c780028
Extended suggestions check
bennycode Apr 26, 2017
d2423e4
Merge branch 'dev' into es6-user
bennycode Apr 27, 2017
08b419d
UserService
bennycode Apr 27, 2017
a5c1136
Merge branch 'dev' into es6-user
bennycode Apr 27, 2017
a7c3b38
Started working on UserMapper...
bennycode Apr 27, 2017
0f2fd2d
UserMapper
bennycode Apr 27, 2017
c825bc5
UserMapper
bennycode Apr 27, 2017
780ed21
Merged with dev
bennycode Apr 28, 2017
849ac04
Updated JSDoc
bennycode Apr 28, 2017
46251e4
Added missing semicolon
bennycode Apr 28, 2017
121d349
Fixing tests
bennycode Apr 28, 2017
4cfc3de
Working on UserRepository
bennycode Apr 28, 2017
60fd5c3
UserRepository.js
bennycode Apr 28, 2017
d4b4832
Down to 2 errors
bennycode Apr 28, 2017
7b7831f
1 error left...
bennycode Apr 28, 2017
b0bf840
Fixed tests
bennycode Apr 28, 2017
e9d0c7f
JSDoc
bennycode Apr 28, 2017
8f1c030
Finished with JSDoc
bennycode May 1, 2017
6fe345b
Merge branch 'dev' into es6-user
bennycode May 1, 2017
db21512
Merge branch 'dev' into es6-user
bennycode May 2, 2017
db99c7e
Merge branch 'dev' into es6-user
bennycode May 2, 2017
febabf9
index
bennycode May 2, 2017
f974718
Merge branch 'dev' into es6-user
bennycode May 2, 2017
4a0ea08
Fixed handle generation
bennycode May 2, 2017
221cf79
Removed mapping
bennycode May 2, 2017
98805f2
[ci skip]
bennycode May 2, 2017
7d6a130
review
bennycode May 2, 2017
d4d8da2
Removed logger return statements
bennycode May 2, 2017
f5fc8df
IDs
bennycode May 2, 2017
9cf58cb
Merge branch 'dev' into es6-user
bennycode May 2, 2017
a6033fb
Merge branch 'dev' into es6-user
bennycode May 3, 2017
ebeaa3e
Fixed props
bennycode May 3, 2017
b433cc1
Merge branch 'dev' into es6-user
bennycode May 3, 2017
a26b2b1
Merge branch 'dev' into es6-user
bennycode May 3, 2017
ebd3f63
Merge branch 'dev' into es6-user
bennycode May 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions app/script/user/ConnectionStatus.coffee

This file was deleted.

33 changes: 33 additions & 0 deletions app/script/user/ConnectionStatus.js
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: '',
};
64 changes: 0 additions & 64 deletions app/script/user/UserConnectionMapper.coffee

This file was deleted.

71 changes: 71 additions & 0 deletions app/script/user/UserConnectionMapper.js
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;
};
}
};
47 changes: 0 additions & 47 deletions app/script/user/UserError.coffee

This file was deleted.

61 changes: 61 additions & 0 deletions app/script/user/UserError.js
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;
Copy link
Contributor

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

}
}

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',
};
}
};
Loading