diff options
Diffstat (limited to 'recipes/rocketchat')
-rw-r--r-- | recipes/rocketchat/index.js | 35 | ||||
-rw-r--r-- | recipes/rocketchat/package.json | 2 | ||||
-rw-r--r-- | recipes/rocketchat/webview.js | 17 |
3 files changed, 32 insertions, 22 deletions
diff --git a/recipes/rocketchat/index.js b/recipes/rocketchat/index.js index a7fee29..a89bd61 100644 --- a/recipes/rocketchat/index.js +++ b/recipes/rocketchat/index.js | |||
@@ -1,18 +1,19 @@ | |||
1 | module.exports = Ferdium => class RocketChat extends Ferdium { | 1 | module.exports = Ferdium => |
2 | async validateUrl(url) { | 2 | class RocketChat extends Ferdium { |
3 | try { | 3 | async validateUrl(url) { |
4 | const resp = await window.fetch(url, { | 4 | try { |
5 | method: 'GET', | 5 | const resp = await window.fetch(url, { |
6 | headers: { | 6 | method: 'GET', |
7 | 'Content-Type': 'application/json', | 7 | headers: { |
8 | }, | 8 | 'Content-Type': 'application/json', |
9 | }); | 9 | }, |
10 | const status = resp.status.toString(); | 10 | }); |
11 | return status.startsWith('2') || status.startsWith('3'); | 11 | const status = resp.status.toString(); |
12 | } catch (error) { | 12 | return status.startsWith('2') || status.startsWith('3'); |
13 | console.error(error); | 13 | } catch (error) { |
14 | } | 14 | console.error(error); |
15 | } | ||
15 | 16 | ||
16 | return false; | 17 | return false; |
17 | } | 18 | } |
18 | }; | 19 | }; |
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 17719ed..164cd5f 100644 --- a/recipes/rocketchat/package.json +++ b/recipes/rocketchat/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "rocketchat", | 2 | "id": "rocketchat", |
3 | "name": "Rocket.Chat", | 3 | "name": "Rocket.Chat", |
4 | "version": "1.3.0", | 4 | "version": "1.4.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.rocket.chat", | 7 | "serviceURL": "https://{teamId}.rocket.chat", |
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js index 85b0c32..74556de 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js | |||
@@ -1,3 +1,8 @@ | |||
1 | function _interopRequireDefault(obj) { | ||
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
1 | 6 | ||
2 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
3 | const getMessages = () => { | 8 | const getMessages = () => { |
@@ -18,30 +23,34 @@ module.exports = Ferdium => { | |||
18 | 23 | ||
19 | Ferdium.loop(getMessages); | 24 | Ferdium.loop(getMessages); |
20 | 25 | ||
26 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
27 | |||
21 | const getTeamIcon = function getTeamIcon() { | 28 | const getTeamIcon = function getTeamIcon() { |
22 | const manifestElement = document.querySelector('link[rel="manifest"]'); | 29 | const manifestElement = document.querySelector('link[rel="manifest"]'); |
23 | 30 | ||
24 | if (manifestElement == null) { | 31 | if (manifestElement === null) { |
25 | return; | 32 | return; |
26 | } | 33 | } |
27 | 34 | ||
28 | const manifestUrl = manifestElement.getAttribute('href'); | 35 | const manifestUrl = manifestElement.getAttribute('href'); |
29 | 36 | ||
30 | if (manifestUrl == null) { | 37 | if (manifestUrl === null) { |
31 | return; | 38 | return; |
32 | } | 39 | } |
33 | 40 | ||
34 | const xmlhttp = new XMLHttpRequest(); | 41 | const xmlhttp = new XMLHttpRequest(); |
35 | 42 | ||
36 | xmlhttp.addEventListener('readystatechange', function () { | 43 | xmlhttp.addEventListener('readystatechange', function () { |
37 | if (this.readyState != 4 || this.status != 200) { | 44 | if (this.readyState !== 4 || this.status !== 200) { |
38 | return; | 45 | return; |
39 | } | 46 | } |
40 | 47 | ||
41 | const response = JSON.parse(this.responseText); | 48 | const response = JSON.parse(this.responseText); |
42 | 49 | ||
43 | if (response.icons.length > 0) { | 50 | if (response.icons.length > 0) { |
44 | Ferdium.setAvatarImage(`${window.location.protocol}//${window.location.host}${response.icons[0].src}`); | 51 | Ferdium.setAvatarImage( |
52 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}`, | ||
53 | ); | ||
45 | } | 54 | } |
46 | }); | 55 | }); |
47 | 56 | ||