Skip to content

Commit

Permalink
Merge pull request #406 from wizarrrr/chore/general-maintenance
Browse files Browse the repository at this point in the history
chore: unraid template, migration error & plex home error
  • Loading branch information
JamsRepos authored May 3, 2024
2 parents 9b784a2 + 78665f6 commit 2bd8fe9
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "**/latest"
- "**/CHANGELOG.md"
- "**/CHANGELOG-beta.md"
- "**/unraid.xml"
- "./scripts/**"
- "./release.config.cjs"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "**/latest"
- "**/CHANGELOG.md"
- "**/CHANGELOG-beta.md"
- "**/unraid.xml"
- "./scripts/**"
- "./release.config.cjs"
workflow_dispatch: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run():
if "hide_user" not in column_names:
db.execute_sql("ALTER TABLE invitations ADD COLUMN hide_user BOOLEAN DEFAULT 1")
elif "live_tv" in column_names:
db.execute_sql("ALTER TABLE invitations ALTER COLUMN live_tv BOOLEAN;")
db.execute_sql("ALTER TABLE invitations ALTER COLUMN live_tv SET DATA TYPE BOOLEAN;")
else:
print("Column hide_user already exists")

Expand Down
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 @@ -128,11 +128,7 @@ export default defineComponent({
plex: {
unlimited: {
label: "Unlimited Invitation Usages",
value: this.invitation.plex_home,
},
plex_home: {
label: "Allow Plex Home Access",
value: this.invitation.plex_home,
value: this.invitation.unlimited,
},
plex_allow_sync: {
label: "Allow Plex Downloads",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ export default defineComponent({
// Sanitize server_url and server_url_override to remove trailing slashes
let server_url = this.serverForm.server_url.trim().replace(/\/$/, "");
let server_url_override = this.serverForm.server_url_override ? this.serverForm.server_url_override.trim().replace(/\/$/, "") : null;
let server_url_override = this.serverForm.server_url_override ? this.serverForm.server_url_override.trim().replace(/\/$/, "") : "";
// Automatically set server_url_override to https://app.plex.tv if it contains plex.tv, otherwise leave it as is
server_url_override = server_url_override && server_url_override.includes('plex.tv') ? 'https://app.plex.tv' : server_url_override;
formData.append("server_name", this.serverForm.server_name);
formData.append("server_url", server_url);
if (this.serverForm.server_url_override) formData.append("server_url_override", server_url_override);
formData.append("server_url_override", server_url_override);
formData.append("server_type", this.serverForm.server_type);
formData.append("server_api_key", this.serverForm.server_api_key);
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
7 changes: 7 additions & 0 deletions develop.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
"files.exclude": {
"**/apps/": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"**/language": true,
"**/apps/wizarr-frontend/src/language": true
},
"commit-message-editor.staticTemplate": ["feat: Short description", "", "Message body", "", "Message footer"],
"commit-message-editor.dynamicTemplate": ["{type}{scope}: {description}", "", "{body}", "", "{skip_ci}", "", "{breaking_change}{footer}"],
"commit-message-editor.tokens": [
Expand Down
16 changes: 12 additions & 4 deletions unraid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<Privileged>false</Privileged>
<Support>https://github.com/Wizarrrr/wizarr/discussions</Support>
<Project>https://github.com/wizarrrr/wizarr</Project>
<Overview>Wizarr is a automatic user invitation system for Plex and Jellyfin. Create a unique link and share it to a user and they will be invited to your Media Server after they complete there signup proccess! They can even be guided to download the clients and read instructions on how to use your media software!&#xD;
<Overview>Wizarr is an automatic user invitation system for Plex, Jellyfin and Emby. Create a unique link and share it to a user and they will be invited to your Media Server after they complete their signup process! They can even be guided to download the clients and read instructions on how to use your media software!&#xD;
&#xD;
NOTE: If you wish to use the beta branch, simple append :beta on the end of the Repository URL. You cannot downgrade once you have switched to the beta branch without formatting.</Overview>
Choose between the stable, beta, or nightly branch as per your requirements. Note: Once you upgrade to the beta version, you cannot downgrade to the stable version without formatting. The nightly build is strictly for development or testers and should not be used in production environments.</Overview>
<Category>MediaServer:Other</Category>
<WebUI>http://[IP]:[PORT:5690]/</WebUI>
<Icon>https://raw.githubusercontent.com/Wizarrrr/wizarr/master/apps/wizarr-frontend/src/assets/img/wizard.png</Icon>
Expand All @@ -20,6 +20,14 @@ NOTE: If you wish to use the beta branch, simple append :beta on the end of the
<CPUset/>
<DateInstalled>1713138518</DateInstalled>
<Requires/>
<Config Name="Data Folder" Target="/data/database" Default="/mnt/user/appdata/wizarr/" Mode="rw" Description="Folder for handling Wizarr related data including database files and cache." Type="Path" Display="always" Required="true" Mask="false">/mnt/user/appdata/wizarr/</Config>
<Config Name="WebUI Port" Target="5690" Default="" Mode="tcp" Description="Port for where you would like Wizarr to reside." Type="Port" Display="always" Required="false" Mask="false">5690</Config>
<Config Name="Repository" Target="Repo" Default="ghcr.io/wizarrrr/wizarr:latest" Mode="rw" Description="Select the Docker image version for Wizarr. 'Stable' for regular use with fewer updates but more tested features; 'Beta' for the latest features but with potential bugs and less stability; 'Nightly' for the most recent changes, for development or testing only, highly unstable." Type="Variable" Display="always" Required="true" Mask="false">
<Option Name="Stable" Value="ghcr.io/wizarrrr/wizarr:latest" Description="The stable version is recommended for most users and offers tested stability and fewer updates to ensure a smooth experience.">
</Option>
<Option Name="Beta" Value="ghcr.io/wizarrrr/wizarr:beta" Description="The beta version includes the latest features and updates but may contain bugs and can be less stable than the stable version. Not recommended for critical environments. Once upgraded, you cannot downgrade without formatting.">
</Option>
<Option Name="Nightly" Value="ghcr.io/wizarrrr/wizarr:nightly" Description="Intended strictly for development or testing. This build pushes the most recent changes, is highly unstable, and should never be used in production environments.">
</Option>
</Config>
<Config Name="Data Folder" Target="/data/database" Default="/mnt/user/appdata/wizarr/" Mode="rw" Description="Folder for handling Wizarr related data including database files and cache." Type="Path" Display="always" Required="true" Mask="false"/>
<Config Name="WebUI Port" Target="5690" Default="" Mode="tcp" Description="Port for where you would like Wizarr to reside." Type="Port" Display="always" Required="false" Mask="false"/>
</Container>

0 comments on commit 2bd8fe9

Please sign in to comment.