Skip to content

Commit

Permalink
Use InfoLinkRes for INFOLINK request.
Browse files Browse the repository at this point in the history
Also check nullish value #114
  • Loading branch information
storycraft committed Feb 1, 2021
1 parent 7a25b51 commit 2c2932a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/packet/chat/info-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { OpenLinkStruct } from "../struct/openlink";

export interface InfoLinkRes {

ols: OpenLinkStruct[];
ols?: OpenLinkStruct[];

}
5 changes: 3 additions & 2 deletions src/talk/openlink/talk-openlink-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { KnownDataStatusCode } from "../../request";
import { structToOpenLink, structToOpenLinkInfo } from "../../packet/struct/wrap/openlink";
import { structToOpenLinkKickedUserInfo } from "../../packet/struct/wrap/user";
import { AsyncCommandResult } from "../../request";
import { InfoLinkRes } from "../../packet/chat/info-link";

/**
* Provides openlink operations
Expand Down Expand Up @@ -46,15 +47,15 @@ export class TalkOpenLinkSession implements OpenLinkSession {
}

async getOpenLink(...components: OpenLinkComponent[]): AsyncCommandResult<Readonly<OpenLink>[]> {
const res = await this._session.request<SyncLinkRes>(
const res = await this._session.request<InfoLinkRes>(
'INFOLINK',
{
'lis': components.map(component => component.linkId)
}
);
if (res.status !== KnownDataStatusCode.SUCCESS) return { status: res.status, success: false };

const list: OpenLink[] = res.ols.map(structToOpenLink);
const list: OpenLink[] = res.ols ? res.ols.map(structToOpenLink) : [];

return { status: res.status, success: true, result: list };
}
Expand Down

0 comments on commit 2c2932a

Please sign in to comment.