Skip to content

Commit

Permalink
Add timestamp and messageId fields, Add new proto definitions (#56)
Browse files Browse the repository at this point in the history
* Added `timestamp` to `WebcastMessageEvent`, `WebcastChatMessageDetails`

* Generic protos at bottom

* `uint32` => `uint64` for field 2 in `WebcastMessageEvent`

* merge `WebcastChatMessageDetails` with `WebcastMessageEvent`

* Rename fields according to TikTok JS definitions

* Remove `method` field from `WebcastMessageEvent`

* Remove `roomId` from `WebcastMessageEvent`

* Add converter function for `WebcastMessageEvent`

* Add `secUid` to user attributes

Co-authored-by: zerodytrash <59258980+zerodytrash@users.noreply.github.com>
  • Loading branch information
carcabot and zerodytrash committed Aug 20, 2022
1 parent 184b783 commit dca5368
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 106 deletions.
9 changes: 8 additions & 1 deletion src/lib/webcastDataConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function simplifyObject(webcastObject) {
}

if (webcastObject.event) {
Object.assign(webcastObject, webcastObject.event);
Object.assign(webcastObject, getEventAttributes(webcastObject.event));
delete webcastObject.event;
}

Expand Down Expand Up @@ -117,6 +117,7 @@ function simplifyObject(webcastObject) {
function getUserAttributes(webcastUser) {
let userAttributes = {
userId: webcastUser.userId?.toString(),
secUid: webcastUser.secUid?.toString(),
uniqueId: webcastUser.uniqueId !== '' ? webcastUser.uniqueId : undefined,
nickname: webcastUser.nickname !== '' ? webcastUser.nickname : undefined,
profilePictureUrl: webcastUser.profilePicture?.urls[2],
Expand All @@ -136,6 +137,12 @@ function getUserAttributes(webcastUser) {
return userAttributes;
}

function getEventAttributes(event) {
if (event.msgId) event.msgId = event.msgId.toString();
if (event.createTime) event.createTime = event.createTime.toString();
return event;
}

function mapBadges(badges) {
let simplifiedBadges = [];

Expand Down

0 comments on commit dca5368

Please sign in to comment.