Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

[NEW] Provide new Livechat Api setCustomFields#313

Merged
d-gubert merged 5 commits intoalphafrom
livechat-setcustomfields
Sep 18, 2020
Merged

[NEW] Provide new Livechat Api setCustomFields#313
d-gubert merged 5 commits intoalphafrom
livechat-setcustomfields

Conversation

@shiqimei
Copy link
Copy Markdown
Contributor

@shiqimei shiqimei commented Sep 11, 2020

What? ⛵

Provide a new Livechat Api by modify.getUpdater().getLivechatUpdater().setCustomFields

Why? 🤔

Links 🌎

https://app.clickup.com/t/24zmb4

PS 👀

PR in the RC side: RocketChat/Rocket.Chat#18912

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 11, 2020

Codecov Report

Merging #313 into alpha will decrease coverage by 2.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            alpha     #313      +/-   ##
==========================================
- Coverage   53.20%   51.18%   -2.02%     
==========================================
  Files          82       74       -8     
  Lines        2934     2819     -115     
  Branches      427      427              
==========================================
- Hits         1561     1443     -118     
- Misses       1373     1376       +3     
Impacted Files Coverage Δ
src/server/accessors/LivechatUpdater.ts 22.22% <0.00%> (-11.12%) ⬇️
src/server/compiler/index.ts
src/server/storage/index.ts
src/server/accessors/index.ts
src/server/logging/index.ts
src/server/bridges/index.ts
src/server/marketplace/license/index.ts
src/server/managers/index.ts
src/server/errors/index.ts

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fc8d4c...a61021e. Read the comment docs.

@shiqimei
Copy link
Copy Markdown
Contributor Author

image

@renatobecker This should be working now, can you please help check?

@shiqimei
Copy link
Copy Markdown
Contributor Author

shiqimei commented Sep 14, 2020

import { IAppAccessors, IHttp, ILogger, IModify, IPersistence, IRead } from '@rocket.chat/apps-engine/definition/accessors';
import { App } from '@rocket.chat/apps-engine/definition/App';
import { ILivechatRoom, IPostLivechatRoomClosed, IPostLivechatRoomStarted } from '@rocket.chat/apps-engine/definition/livechat';
import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';

export class LivechatSetcustomfieldsApp extends App implements IPostLivechatRoomStarted, IPostLivechatRoomClosed {
    constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
        super(info, logger, accessors);
    }

    public async executePostLivechatRoomStarted(room: ILivechatRoom, read: IRead, http: IHttp, persis: IPersistence, modify?: IModify): Promise<void> {
        const { visitor } = room;
        console.log('executePostLivechatRoomStarted', visitor);

        if (modify) {
            await modify.getUpdater().getLivechatUpdater().setCustomFields(visitor.token, 'test', 'value', true);
        }
    }

    public async executePostLivechatRoomClosed(room: ILivechatRoom, read: IRead, http: IHttp, persis: IPersistence, modify?: IModify): Promise<void> {
        const { visitor } = room;
        console.log('executePostLivechatRoomClosed', visitor);
    }
}

@d-gubert
Copy link
Copy Markdown
Member

This requires changes on the Rocket.Chat side as well, right?

@thassiov
Copy link
Copy Markdown
Contributor

LGTM

@d-gubert d-gubert merged commit 71494ec into alpha Sep 18, 2020
@d-gubert d-gubert deleted the livechat-setcustomfields branch September 18, 2020 22:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants