Skip to content

fix: importing friends #3551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 2 additions & 30 deletions server/api/plextv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,6 @@ interface ServerResponse {
};
}

interface FriendResponse {
MediaContainer: {
User: {
$: {
id: string;
title: string;
username: string;
email: string;
thumb: string;
};
Server?: ServerResponse[];
}[];
};
}

interface UsersResponse {
MediaContainer: {
User: {
Expand Down Expand Up @@ -234,19 +219,6 @@ class PlexTvAPI extends ExternalAPI {
}
}

public async getFriends(): Promise<FriendResponse> {
const response = await this.axios.get('/pms/friends/all', {
transformResponse: [],
responseType: 'text',
});

const parsedXml = (await xml2js.parseStringPromise(
response.data
)) as FriendResponse;

return parsedXml;
}

public async checkUserAccess(userId: number): Promise<boolean> {
const settings = getSettings();

Expand All @@ -255,9 +227,9 @@ class PlexTvAPI extends ExternalAPI {
throw new Error('Plex is not configured!');
}

const friends = await this.getFriends();
const usersResponse = await this.getUsers();

const users = friends.MediaContainer.User;
const users = usersResponse.MediaContainer.User;

const user = users.find((u) => parseInt(u.$.id) === userId);

Expand Down