Skip to content

Commit

Permalink
Merge branch 'main' into pr/35
Browse files Browse the repository at this point in the history
  • Loading branch information
tnfAngel authored Nov 23, 2024
2 parents b4a2788 + 65b3e3f commit 3aeae9c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@fnlb-project/fnbr",
"name": "fnbr",
"version": "4.1.0",
"description": "A library to interact with Epic Games' Fortnite HTTP and XMPP services",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
},
"scripts": {
"build": "node generateExports.js && npx tsc",
"lint": "eslint src/**/*.ts resources/**/*.ts enums/**/*.ts",
Expand Down
9 changes: 9 additions & 0 deletions resources/structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,15 @@ export interface EOSAuthData extends AuthData {
scope: string;
}

export interface EOSAuthData extends AuthData {
refresh_expires: number;
refresh_expires_at: string;
refresh_token: string;
application_id: string;
merged_accounts: string[];
scope: string;
}

export interface AuthSessionStore<K, V> extends Collection<K, V> {
get(key: AuthSessionStoreKey.Fortnite): FortniteAuthSession | undefined;
get(key: AuthSessionStoreKey.Launcher): LauncherAuthSession | undefined;
Expand Down
59 changes: 35 additions & 24 deletions src/structures/party/PartyChat.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
import { deprecate } from 'util';
import Base from '../../Base';
import AsyncLock from '../../util/AsyncLock';
import PartyMessage from './PartyMessage';
import PartyChatConversationNotFoundError from '../../exceptions/PartyChatConversationNotFoundError';
import type Client from '../../Client';
import type ClientParty from './ClientParty';
import type ClientPartyMember from './ClientPartyMember';

const deprecationNotOverXmppAnymore = 'Party Chat is not done over XMPP anymore, this function will be removed in a future version';

/**
* Represents a party's conversation
*/
class PartyChat extends Base {
/**
* The chat room's JID
* @deprecated since chat is not done over xmpp anymore, this property will always be an empty string
* @deprecated since chat is not done over xmpp anymore, this property will always be an empty string and will be removed in a future version
*/
public jid: string;

/**
* the party chats conversation id
* the party chat's conversation id
*/
public get conversationId() {
return `p-${this.party.id}`;
}

/**
* The client's chat room nickname
* @deprecated since chat is not done over xmpp anymore, this property will always be an empty string
* @deprecated since chat is not done over xmpp anymore, this property will always be an empty string and will be removed in a future version
*/
public nick: string;

/**
* The chat room's join lock
* @deprecated since chat is not done over xmpp anymore, this is not used anymore
* @deprecated since chat is not done over xmpp anymore, this is not used anymore and will be removed in a future version
*/
public joinLock: AsyncLock;

Expand All @@ -41,7 +45,7 @@ class PartyChat extends Base {

/**
* Whether the client is connected to the party chat
* @deprecated since chat is not done over xmpp anymore, this property will always be true
* @deprecated since chat is not done over xmpp anymore, this property will always be true and will be removed in a future version
*/
public isConnected: boolean;

Expand All @@ -62,9 +66,9 @@ class PartyChat extends Base {
this.nick = '';
this.jid = '';
this.isConnected = true;
this.bannedAccountIds = new Set();

this.party = party;
this.bannedAccountIds = new Set<string>();
}

/**
Expand All @@ -73,13 +77,16 @@ class PartyChat extends Base {
* @throws {PartyChatConversationNotFoundError} When the client is the only party member
*/
public async send(content: string) {
if (this.party.members.size < 2) {
throw new PartyChatConversationNotFoundError();
}

const messageId = await this.client.chat.sendMessageInConversation(
this.conversationId,
{
body: content,
},
this.party.members
.filter((x) => !this.bannedAccountIds.has(x.id))
.map((x) => x.id),
);

Expand All @@ -93,32 +100,36 @@ class PartyChat extends Base {

/**
* Joins this party chat
* @deprecated since chat is not done over xmpp anymore, this function will do nothing
* @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version
*/
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
public async join() { }
// eslint-disable-next-line class-methods-use-this
public async join() {
const deprecatedFn = deprecate(() => { }, deprecationNotOverXmppAnymore);

return deprecatedFn();
}

/**
* Leaves this party chat
* @deprecated since chat is not done over xmpp anymore, this function will do nothing
* @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version
*/
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
public async leave() { }
// eslint-disable-next-line class-methods-use-this
public async leave() {
const deprecatedFn = deprecate(() => { }, deprecationNotOverXmppAnymore);

/**
* Ban a member from receiving party messages from the logged in user
* @param member The member that should be banned
*/
public async ban(member: string) {
this.bannedAccountIds.add(member);
return deprecatedFn();
}

/**
* Unban a member from receiving party messages from the logged in user
* @param member The member that should be unbanned
*/
public async unban(member: string) {
this.bannedAccountIds.delete(member);
* Ban a member from this party chat
* @param member The member that should be banned
* @deprecated since chat is not done over xmpp anymore, this function will do nothing and will be removed in a future version
*/
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
public async ban(member: string) {
const deprecatedFn = deprecate(() => { }, deprecationNotOverXmppAnymore);

return deprecatedFn();
}
}

Expand Down

0 comments on commit 3aeae9c

Please sign in to comment.