Skip to content

Commit

Permalink
fix: 🩹 Removed plex home configuration due to not existing in the Ple…
Browse files Browse the repository at this point in the history
…x API
  • Loading branch information
JamsRepos committed May 3, 2024
1 parent affa9ff commit a075079
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# CREATED ON VERSION: V4.1.0b1
# MIGRATION: 2024-05-03_22-33-10
# CREATED: Fri May 03 2024
#

from peewee import *
from playhouse.migrate import *

from app import db

# Do not change the name of this file,
# migrations are run in order of their filenames date and time

def run():
# Use migrator to perform actions on the database
migrator = SqliteMigrator(db)

# Remove column plex_home from invitations table
with db.transaction():
# Check if the column exists
cursor = db.cursor()
cursor.execute("PRAGMA table_info(invitations);")
columns = cursor.fetchall()
column_names = [column[1] for column in columns]

if "plex_home" in column_names:
# drop the column plex_home
db.execute_sql("ALTER TABLE invitations DROP COLUMN plex_home")
else:
print("Column plex_home already dropped")

print("Migration 2024-05-03_22-33-10 complete")
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Invitations(BaseModel):
duration = CharField(null=True, default=None) # How long the membership is kept for
specific_libraries = CharField(default=None, null=True)
plex_allow_sync = BooleanField(null=True, default=None)
plex_home = BooleanField(null=True, default=None)
sessions = CharField(null=True, default=None)
live_tv = BooleanField(null=True, default=None)
hide_user = BooleanField(null=True, default=True)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class InvitationsModel(Model):
plex_allow_sync = BooleanType(required=False, default=False)
sessions = IntType(required=False, default=None)
live_tv = BooleanType(required=False, default=True)
plex_home = BooleanType(required=False, default=False)
used_at = DateTimeType(required=False, default=None, convert_tz=True)
created = DateTimeType(required=False, default=datetime.utcnow(), convert_tz=True)
hide_user = BooleanType(required=False, default=True)
Expand Down
8 changes: 2 additions & 6 deletions apps/wizarr-backend/wizarr_backend/helpers/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,15 @@ def invite_plex_user(code: str, token: str, server_api_key: Optional[str] = None
if invitation.specific_libraries is not None and len(invitation.specific_libraries) > 0:
sections = [library.name for library in Libraries.filter(Libraries.id.in_(invitation.specific_libraries.split(",")))]

# Get allow_sync and plex_home from invitation
# Get allow_sync from invitation
allow_sync = invitation.plex_allow_sync
plex_home = invitation.plex_home

# Get my account from Plex
my_account = plex.myPlexAccount()

# Get the user from the token
plex_account = MyPlexAccount(token=token)

# Select invitation method
invite_method = my_account.createHomeUser if plex_home else my_account.inviteFriend

invite_data = {
"user": plex_account.email,
"server": plex,
Expand All @@ -131,7 +127,7 @@ def invite_plex_user(code: str, token: str, server_api_key: Optional[str] = None
invite_data["sections"] = sections

# Invite the user
invite = invite_method(**invite_data)
invite = my_account.inviteFriend(**invite_data)

# If the invite is none raise an error
if invite is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ export default defineComponent({
label: "Unlimited Invitation Usages",
value: "unlimited",
},
plex_home: {
label: "Allow Plex Home Access",
value: "plex_home",
},
plex_allow_sync: {
label: "Allow Plex Downloads",
value: "plex_allow_sync",
Expand Down Expand Up @@ -270,7 +266,6 @@ export default defineComponent({
const code = invitationData.inviteCode;
const expires = invitationData.expiration == "custom" ? this.$filter("toMinutes", invitationData.customExpiration) : invitationData.expiration;
const unlimited = invitationData.checkboxes.includes("unlimited");
const plex_home = invitationData.checkboxes.includes("plex_home");
const plex_allow_sync = invitationData.checkboxes.includes("plex_allow_sync");
const live_tv = invitationData.checkboxes.includes("live_tv");
const hide_user = invitationData.checkboxes.includes("hide_user");
Expand All @@ -282,7 +277,6 @@ export default defineComponent({
code: code,
expires: expires,
unlimited: unlimited,
plex_home: plex_home,
plex_allow_sync: plex_allow_sync,
live_tv: live_tv,
hide_user: hide_user,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ export default defineComponent({
label: "Unlimited Invitation Usages",
value: this.invitation.unlimited,
},
plex_home: {
label: "Allow Plex Home Access",
value: this.invitation.plex_home,
},
plex_allow_sync: {
label: "Allow Plex Downloads",
value: this.invitation.plex_allow_sync,
Expand Down
1 change: 0 additions & 1 deletion apps/wizarr-frontend/src/types/api/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface Invitation {
expires: string;
id: number;
plex_allow_sync: boolean;
plex_home: boolean;
live_tv: boolean;
hide_user: boolean;
sessions: number;
Expand Down

0 comments on commit a075079

Please sign in to comment.