mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-16 07:04:24 -04:00
Breaking API change.
This commit is contained in:
+2
-1
@@ -2,4 +2,5 @@ node_modules
|
||||
old_src
|
||||
dist
|
||||
.vscode
|
||||
.env
|
||||
.env
|
||||
h.js
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "4.1.0-alpha.0",
|
||||
"version": "4.1.0-alpha.1",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
@@ -26,6 +26,7 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"fake-indexeddb": "^3.1.2",
|
||||
"in-publish": "^2.0.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.0-dev.20200208"
|
||||
},
|
||||
|
||||
+7
-5
@@ -87,10 +87,12 @@ export class Client extends EventEmitter {
|
||||
|
||||
if (channel.channel_type === 'DirectMessage' ||
|
||||
channel.channel_type === 'Group') {
|
||||
channel.last_message = {
|
||||
_id: message._id,
|
||||
author: message.author,
|
||||
short: message.content.substr(0, 32)
|
||||
if (typeof message.content === 'string') {
|
||||
channel.last_message = {
|
||||
_id: message._id,
|
||||
author: message.author,
|
||||
short: message.content.substr(0, 32)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -101,7 +103,7 @@ export class Client extends EventEmitter {
|
||||
await this.channels.restore();
|
||||
this.users.set({
|
||||
_id: SYSTEM_USER_ID,
|
||||
username: 'revolt'
|
||||
username: 'REVOLT'
|
||||
});
|
||||
if (user_id) this.user = this.users.get(user_id);
|
||||
}
|
||||
|
||||
+3
-2
@@ -97,7 +97,7 @@ export namespace Channels {
|
||||
channel: string,
|
||||
author: string,
|
||||
|
||||
content: string,
|
||||
content: string | SystemMessage,
|
||||
attachment?: Attachment,
|
||||
edited?: { $date: string }
|
||||
}
|
||||
@@ -106,7 +106,8 @@ export namespace Channels {
|
||||
| { type: "text"; content: string }
|
||||
| { type: "user_added"; id: string; by: string }
|
||||
| { type: "user_remove"; id: string; by: string }
|
||||
| { type: "user_left"; id: string };
|
||||
| { type: "user_left"; id: string }
|
||||
| { type: "channel_renamed"; name: string, by: string };
|
||||
}
|
||||
|
||||
export type User = Users.User;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
export * from './Client';
|
||||
export { Channel, User, Message } from './api/objects';
|
||||
|
||||
export const LIBRARY_VERSION = '4.1.0-alpha.0';
|
||||
export const LIBRARY_VERSION = '4.1.0-alpha.1';
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: 'https://api.revolt.chat',
|
||||
|
||||
@@ -119,13 +119,14 @@ export class WebSocketClient {
|
||||
this.client.messages.push(packet._id);
|
||||
|
||||
if (packet.author === SYSTEM_USER_ID) {
|
||||
let system = this.client.channels.tryParseSystemMessage(packet.content);
|
||||
switch (system.type) {
|
||||
case 'user_added':
|
||||
case 'user_remove':
|
||||
await this.client.users.fetch(system.by);
|
||||
case 'user_left':
|
||||
await this.client.users.fetch(system.id);
|
||||
if (typeof packet.content === 'object') {
|
||||
switch (packet.content.type) {
|
||||
case 'user_added':
|
||||
case 'user_remove':
|
||||
await this.client.users.fetch(packet.content.by);
|
||||
case 'user_left':
|
||||
await this.client.users.fetch(packet.content.id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await this.client.users.fetch(packet.author);
|
||||
|
||||
@@ -365,6 +365,11 @@ node-cleanup@^2.1.2:
|
||||
resolved "https://registry.yarnpkg.com/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c"
|
||||
integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw=
|
||||
|
||||
node-fetch@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
|
||||
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||
|
||||
object-hash@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.1.1.tgz#9447d0279b4fcf80cff3259bf66a1dc73afabe09"
|
||||
|
||||
Reference in New Issue
Block a user