bulbul-chat
Advanced tools
Comparing version 3.1.1 to 3.2.0
{ | ||
"name": "bulbul-chat", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -168,2 +168,3 @@ export declare type ChatMessageType = 'plaintext' | 'image' | 'video' | 'audio' | 'document' | 'location' | 'contact' | 'file' | 'url' | 'card'; | ||
sendAttachment(chatMessage: ChatMessage, file: any, onUploadProgress?: (progress: number) => any): Promise<any>; | ||
sendMessageExternally(chatMessage: ChatMessage): Promise<void>; | ||
blockUser(blockedId: string): Promise<any>; | ||
@@ -170,0 +171,0 @@ unBlockUser(blockedId: string): Promise<any>; |
@@ -587,2 +587,5 @@ "use strict"; | ||
}; | ||
ChatClient.prototype.sendMessageExternally = function (chatMessage) { | ||
return this.executeHTTP('POST', '/api/client/chat/sendMessage', __assign({}, chatMessage), {}); | ||
}; | ||
ChatClient.prototype.blockUser = function (blockedId) { | ||
@@ -589,0 +592,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -38,2 +38,3 @@ import ChannelMessageStorage from './ChannelMessageStorage'; | ||
sendAttachment(channelId: string, messageType: ChatMessageType, content: string, file: any, replyTo?: ChatMessage | null, localId?: string, onUploadProgress?: (progress: number) => any): Promise<void>; | ||
sendMessageExternally(channelId: string, messageType: ChatMessageType, content: string, metadata?: Record<string, unknown>, replyToId?: string): Promise<void>; | ||
loadEarlier(channelId: string): Promise<void>; | ||
@@ -40,0 +41,0 @@ loadLater(channelId: string): Promise<void>; |
@@ -540,2 +540,26 @@ "use strict"; | ||
}; | ||
ChatService.prototype.sendMessageExternally = function (channelId, messageType, content, metadata, replyToId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var currentUser, chatMessage; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getCurrentUser()]; | ||
case 1: | ||
currentUser = _a.sent(); | ||
chatMessage = { | ||
localId: (0, uuid_1.v4)(), | ||
channelId: channelId, | ||
messageType: messageType, | ||
content: content, | ||
postedAt: new Date(), | ||
createdAt: new Date().toString(), | ||
senderId: currentUser === null || currentUser === void 0 ? void 0 : currentUser.id, | ||
metadata: metadata, | ||
replyToId: replyToId || null, | ||
}; | ||
return [2 /*return*/, this.chatClient.sendMessageExternally(chatMessage)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ChatService.prototype.loadEarlier = function (channelId) { | ||
@@ -542,0 +566,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "bulbul-chat", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -694,2 +694,11 @@ import * as qs from 'qs'; | ||
sendMessageExternally(chatMessage: ChatMessage): Promise<void> { | ||
return this.executeHTTP( | ||
'POST', | ||
'/api/client/chat/sendMessage', | ||
{ ...chatMessage }, | ||
{} | ||
); | ||
} | ||
async blockUser(blockedId: string) { | ||
@@ -696,0 +705,0 @@ return this.executeHTTP( |
@@ -496,2 +496,25 @@ import { diffInSeconds } from './utils'; | ||
async sendMessageExternally( | ||
channelId: string, | ||
messageType: ChatMessageType, | ||
content: string, | ||
metadata?: Record<string, unknown>, | ||
replyToId?: string | ||
) { | ||
const currentUser = await this.getCurrentUser(); | ||
// validate messageType | ||
const chatMessage: ChatMessage = { | ||
localId: uuidv4(), | ||
channelId, | ||
messageType, | ||
content, | ||
postedAt: new Date(), | ||
createdAt: new Date().toString(), | ||
senderId: currentUser?.id, | ||
metadata, | ||
replyToId: replyToId || null, | ||
}; | ||
return this.chatClient.sendMessageExternally(chatMessage); | ||
} | ||
async loadEarlier(channelId: string) { | ||
@@ -498,0 +521,0 @@ const channelMessageStorage = this.channelMessageStorage(channelId); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
311566
5614