@pusher/chatkit-server
Advanced tools
Comparing version 2.2.0 to 2.4.0
@@ -10,2 +10,9 @@ # Changelog | ||
## [2.4.0](https://github.com/pusher/chatkit-server-node/compare/2.2.0...2.4.0) | ||
### Additions | ||
- Adds message editing via `edit{Simple,Multipart,}Message`. | ||
## 2.3.0 Yanked | ||
## [2.2.0](https://github.com/pusher/chatkit-server-node/compare/2.1.1...2.2.0) | ||
@@ -12,0 +19,0 @@ |
{ | ||
"name": "@pusher/chatkit-server", | ||
"description": "Pusher Chatkit server SDK", | ||
"version": "2.2.0", | ||
"version": "2.4.0", | ||
"main": "target/src/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
{ | ||
"name": "@pusher/chatkit-server", | ||
"description": "Pusher Chatkit server SDK", | ||
"version": "2.2.0", | ||
"version": "2.4.0", | ||
"main": "target/src/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -42,2 +42,10 @@ /// <reference types="node" /> | ||
} | ||
export interface EditMessageOptions extends UserIdOptions { | ||
text: string; | ||
attachment?: AttachmentOptions; | ||
} | ||
export interface EditMultipartMessageOptions { | ||
userId: string; | ||
parts: Array<NewPart>; | ||
} | ||
export interface DeleteMessageOptions { | ||
@@ -230,2 +238,5 @@ messageId: string; | ||
sendMultipartMessage(options: SendMultipartMessageOptions): Promise<any>; | ||
editMessage(roomId: string, messageId: string, options: EditMessageOptions): Promise<void>; | ||
editSimpleMessage(roomId: string, messageId: string, options: EditMessageOptions): Promise<void>; | ||
editMultipartMessage(roomId: string, messageId: string, options: EditMultipartMessageOptions): Promise<void>; | ||
private uploadAttachment; | ||
@@ -232,0 +243,0 @@ deleteMessage(options: DeleteMessageOptions): Promise<void>; |
@@ -233,2 +233,50 @@ "use strict"; | ||
} | ||
editMessage(roomId, messageId, options) { | ||
let messagePayload = { text: options.text }; | ||
if (options.attachment) { | ||
messagePayload.attachment = { | ||
resource_link: options.attachment.resourceLink, | ||
type: options.attachment.type, | ||
}; | ||
} | ||
return this.serverInstanceV2 | ||
.request({ | ||
method: "PUT", | ||
path: `/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(messageId)}`, | ||
jwt: this.generateAccessToken({ | ||
su: true, | ||
userId: options.userId, | ||
}).token, | ||
body: messagePayload, | ||
}) | ||
.then(() => { }); | ||
} | ||
editSimpleMessage(roomId, messageId, options) { | ||
return this.editMultipartMessage(roomId, messageId, { | ||
userId: options.userId, | ||
parts: [{ type: "text/plain", content: options.text }], | ||
}); | ||
} | ||
editMultipartMessage(roomId, messageId, options) { | ||
if (options.parts.length === 0) { | ||
return Promise.reject(new TypeError("message must contain at least one part")); | ||
} | ||
return Promise.all(options.parts.map((part) => part.file | ||
? this.uploadAttachment({ | ||
userId: options.userId, | ||
roomId: roomId, | ||
part, | ||
}) | ||
: part)) | ||
.then(parts => this.serverInstance.request({ | ||
method: "PUT", | ||
path: `/rooms/${encodeURIComponent(roomId)}/messages/${encodeURIComponent(messageId)}`, | ||
jwt: this.generateAccessToken({ | ||
su: true, | ||
userId: options.userId, | ||
}).token, | ||
body: { parts }, | ||
})) | ||
.then(() => { }); | ||
} | ||
uploadAttachment({ userId, roomId, part: { type, name, customData, file }, }) { | ||
@@ -235,0 +283,0 @@ return this.serverInstance |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
71766
1032
0