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

Integrate react-native-network-client #5499

Merged
merged 56 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
48f3b28
fix: handle NSMutableData
migbot Jun 25, 2021
15e0684
feat: integrate react-native-network-client
migbot Jun 29, 2021
00a8011
fix: typos
migbot Jun 29, 2021
e75abc8
Merge branch 'gekidou' into gekidou-network-clients
migbot Jun 29, 2021
fc13ce7
fix: semicolon
migbot Jun 29, 2021
483bd9e
fix: rename to urlVersion
migbot Jun 29, 2021
4d58d03
fix: add returnDataOnly arg
migbot Jun 29, 2021
50503e9
fix: configure network client
migbot Jun 29, 2021
7393f7b
fix: headers
migbot Jun 29, 2021
5d9adcb
fix: handling of serverVersion
migbot Jun 29, 2021
b193838
fix: rename requests to actions
migbot Jun 29, 2021
bb9f5cb
fix: action imports
migbot Jun 29, 2021
6c4935a
fix: no need to stringify body
migbot Jun 29, 2021
03be857
fix: sso flow
migbot Jun 29, 2021
864be4e
fix: address PR feedback
migbot Jul 1, 2021
4108154
fix: invalidate client on logout
migbot Jul 1, 2021
b488a18
fix: address PR feedback take 2
migbot Jul 1, 2021
47b115c
fix: address PR feedback take 3
migbot Jul 1, 2021
a9d6f9b
fix: tsc issues
migbot Jul 1, 2021
d8f4b2d
fix: get csrf token during client creation
migbot Jul 1, 2021
7fab95e
fix: linter
migbot Jul 1, 2021
aa4de0d
fix: invalidate client onLogout
migbot Jul 1, 2021
51372ce
fix: event emitter
migbot Jul 1, 2021
f68b0ee
fix: unit tests
migbot Jul 1, 2021
3eab409
fix: apply linter fixes
migbot Jul 1, 2021
d2724f4
fix lint
enahum Jul 1, 2021
f09b2c9
Modify actions to add / update database values
enahum Jul 1, 2021
29e9734
Rename clien4.d.ts to client.d.ts
enahum Jul 1, 2021
c5a823f
fix empty & missing translations
enahum Jul 1, 2021
8e4024f
cleanup api client
enahum Jul 1, 2021
340bcb5
Cleanup init & squash some TODO's
enahum Jul 1, 2021
e2a55ce
Emit certificate errors in NetworkManager
enahum Jul 2, 2021
cccc182
Merge branch 'gekidou' into gekidou-network-clients
enahum Jul 2, 2021
f839c80
cleanup user actions
enahum Jul 2, 2021
c77e2ca
Fix NetworkManager invalidate client
enahum Jul 2, 2021
be26b45
Invalidate client when server screen appears
enahum Jul 2, 2021
4b23310
Update kotlin to 1.4.30 required by network-client
enahum Jul 2, 2021
ce22a29
patch react-native-keychain to remove cached credential
enahum Jul 3, 2021
ba70408
update react-native-network-client
enahum Jul 3, 2021
181d65e
Use app.db instead of default.db in native code
enahum Jul 3, 2021
e98f55f
fix use of rnnc on Android
enahum Jul 3, 2021
beeac73
Init PushNotifications
enahum Jul 3, 2021
cd150ff
No need to reset serverVersion on logout
enahum Jul 3, 2021
e8bc57a
fix logout action
enahum Jul 3, 2021
b674ac3
fix deleteServerDatabase
enahum Jul 3, 2021
899048f
fix schedule expired session notification
enahum Jul 3, 2021
56fcd51
use safeParseJSON for db json fields
enahum Jul 3, 2021
a516413
unsubscribe when database component unmounts
enahum Jul 3, 2021
5bed596
cleanup init
enahum Jul 3, 2021
0f0cb39
session type
enahum Jul 3, 2021
efa867f
pass launchprops to entire login flow
enahum Jul 3, 2021
ef0469c
Properly remove third party cookies after SSO login
enahum Jul 3, 2021
2c3cb7b
recreate network client if sso with redirect fails
enahum Jul 3, 2021
81ca9db
add missing launch props from server screen
enahum Jul 3, 2021
d730ce9
use query prefix for database queries
enahum Jul 3, 2021
57017e6
Add temporary logout function to channel screen
enahum Jul 3, 2021
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
239 changes: 78 additions & 161 deletions app/client/rest/base.ts

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions app/client/rest/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ export interface ClientGeneralMix {
const ClientGeneral = (superclass: any) => class extends superclass {
getOpenGraphMetadata = async (url: string) => {
return this.doFetch(
`${this.getBaseRoute()}/opengraph`,
`${this.apiVersion}/opengraph`,
{method: 'post', body: JSON.stringify({url})},
);
};

ping = async () => {
return this.doFetch(
`${this.getBaseRoute()}/system/ping?time=${Date.now()}`,
`${this.apiVersion}/system/ping?time=${Date.now()}`,
{method: 'get'},
);
};

logClientError = async (message: string, level = 'ERROR') => {
const url = `${this.getBaseRoute()}/logs`;
const url = `${this.apiVersion}/logs`;

if (!this.enableLogging) {
throw new ClientError(this.getUrl(), {
throw new ClientError(this.client.baseUrl, {
message: 'Logging disabled.',
url,
});
Expand All @@ -50,14 +50,14 @@ const ClientGeneral = (superclass: any) => class extends superclass {

getClientConfigOld = async () => {
return this.doFetch(
`${this.getBaseRoute()}/config/client?format=old`,
`${this.apiVersion}/config/client?format=old`,
{method: 'get'},
);
};

getClientLicenseOld = async () => {
return this.doFetch(
`${this.getBaseRoute()}/license/client?format=old`,
`${this.apiVersion}/license/client?format=old`,
{method: 'get'},
);
};
Expand Down
8 changes: 4 additions & 4 deletions app/client/rest/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ClientGroupsMix {
const ClientGroups = (superclass: any) => class extends superclass {
getGroups = async (filterAllowReference = false, page = 0, perPage = PER_PAGE_DEFAULT, since = 0) => {
return this.doFetch(
`${this.getBaseRoute()}/groups${buildQueryString({filter_allow_reference: filterAllowReference, page, per_page: perPage, since})}`,
`${this.apiVersion}/groups${buildQueryString({filter_allow_reference: filterAllowReference, page, per_page: perPage, since})}`,
{method: 'get'},
);
};
Expand All @@ -29,21 +29,21 @@ const ClientGroups = (superclass: any) => class extends superclass {
}
getAllGroupsAssociatedToTeam = async (teamID: string, filterAllowReference = false) => {
return this.doFetch(
`${this.getBaseRoute()}/teams/${teamID}/groups${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
`${this.apiVersion}/teams/${teamID}/groups${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
{method: 'get'},
);
};

getAllGroupsAssociatedToChannelsInTeam = async (teamID: string, filterAllowReference = false) => {
return this.doFetch(
`${this.getBaseRoute()}/teams/${teamID}/groups_by_channels${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
`${this.apiVersion}/teams/${teamID}/groups_by_channels${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
{method: 'get'},
);
};

getAllGroupsAssociatedToChannel = async (channelID: string, filterAllowReference = false) => {
return this.doFetch(
`${this.getBaseRoute()}/channels/${channelID}/groups${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
`${this.apiVersion}/channels/${channelID}/groups${buildQueryString({paginate: false, filter_allow_reference: filterAllowReference})}`,
{method: 'get'},
);
};
Expand Down
11 changes: 7 additions & 4 deletions app/client/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class Client extends mix(ClientBase).with(
ClientTeams,
ClientTos,
ClientUsers,
) {}
) {
// TODO: types
constructor(client, serverUrl) {
super(client, serverUrl)
}
}

const Client4 = new Client();

export {Client4, Client, DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID};
export {Client, DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID};
2 changes: 1 addition & 1 deletion app/client/rest/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ClientIntegrations = (superclass: any) => class extends superclass {
submitInteractiveDialog = async (data: DialogSubmission) => {
this.analytics.trackAPI('api_interactive_messages_dialog_submitted');
return this.doFetch(
`${this.getBaseRoute()}/actions/dialogs/submit`,
`${this.apiVersion}/actions/dialogs/submit`,
{method: 'post', body: JSON.stringify(data)},
);
};
Expand Down
2 changes: 1 addition & 1 deletion app/client/rest/tos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ClientTos = (superclass: any) => class extends superclass {

getTermsOfService = async () => {
return this.doFetch(
`${this.getBaseRoute()}/terms_of_service`,
`${this.apiVersion}/terms_of_service`,
{method: 'get'},
);
}
Expand Down
20 changes: 11 additions & 9 deletions app/client/rest/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ const ClientUsers = (superclass: any) => class extends superclass {
body.ldap_only = 'true';
}

const {data} = await this.doFetchWithResponse(
const {data} = await this.doFetch(
`${this.getUsersRoute()}/login`,
{
method: 'post',
body: JSON.stringify(body),
body,
headers: {'Cache-Control': 'no-store'},
},
);
Expand All @@ -163,7 +163,7 @@ const ClientUsers = (superclass: any) => class extends superclass {
token,
};

const {data} = await this.doFetchWithResponse(
const {data} = await this.doFetch(
`${this.getUsersRoute()}/login`,
{method: 'post', body: JSON.stringify(body)},
);
Expand All @@ -172,18 +172,20 @@ const ClientUsers = (superclass: any) => class extends superclass {
};

logout = async () => {
this.analytics.trackAPI('api_users_logout');
// this.analytics.trackAPI('api_users_logout');

const {response} = await this.doFetchWithResponse(
const {response} = await this.doFetch(
`${this.getUsersRoute()}/logout`,
{method: 'post'},
);

if (response.ok) {
this.token = '';
}
// TODO: Invalidate client?
migbot marked this conversation as resolved.
Show resolved Hide resolved
// if (response.ok) {
// this.token = '';
// }
migbot marked this conversation as resolved.
Show resolved Hide resolved

this.serverVersion = '';
// TODO: Remove server version from DB?
migbot marked this conversation as resolved.
Show resolved Hide resolved
// this.serverVersion = '';
migbot marked this conversation as resolved.
Show resolved Hide resolved

return response;
};
Expand Down
145 changes: 0 additions & 145 deletions app/init/fetch.js

This file was deleted.

Loading