Skip to content

Commit

Permalink
Merge pull request #418 from madeofpendletonwool/bug-fixes
Browse files Browse the repository at this point in the history
Implemented Notifications
  • Loading branch information
madeofpendletonwool authored Feb 6, 2025
2 parents 5ca7ae0 + 115c015 commit 5f41489
Show file tree
Hide file tree
Showing 12 changed files with 1,481 additions and 30 deletions.
59 changes: 51 additions & 8 deletions .github/workflows/build-flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,58 @@ jobs:
- name: Install Flatpak SDK
run: |
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user -y flathub org.gnome.Platform//46 org.gnome.Sdk//46
flatpak install --user -y flathub org.gnome.Platform//47 org.gnome.Sdk//47
- name: Clone Flathub repo
run: |
git clone https://github.com/flathub/com.gooseberrydevelopment.pinepods flathub-repo
cp flathub-repo/com.gooseberrydevelopment.pinepods.yml .
- name: Set VERSION variable
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
LATEST_RELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "VERSION=$LATEST_RELEASE" >> $GITHUB_ENV
fi
- name: Download DEBs and calculate checksums
run: |
# Download both DEBs
curl -L "https://github.com/${{ github.repository }}/releases/download/$VERSION/Pinepods_${VERSION}_amd64.deb" -o amd64.deb
curl -L "https://github.com/${{ github.repository }}/releases/download/$VERSION/Pinepods_${VERSION}_arm64.deb" -o arm64.deb
# Calculate and display checksums
AMD64_SHA256=$(sha256sum amd64.deb | cut -d' ' -f1)
ARM64_SHA256=$(sha256sum arm64.deb | cut -d' ' -f1)
echo "Calculated AMD64 SHA256: $AMD64_SHA256"
echo "Calculated ARM64 SHA256: $ARM64_SHA256"
# Export to environment
echo "AMD64_SHA256=$AMD64_SHA256" >> $GITHUB_ENV
echo "ARM64_SHA256=$ARM64_SHA256" >> $GITHUB_ENV
- name: Update manifest version and URL
run: |
sed -i "s|url: .*|url: https://github.com/${{ github.repository }}/releases/download/$VERSION/pinepods_${VERSION}_amd64.deb|" clients/flatpak/com.gooseberrydevelopment.pinepods.yml
DEB_URL=$(grep url clients/flatpak/com.gooseberrydevelopment.pinepods.yml | awk '{print $2}')
SHA256=$(curl -sL $DEB_URL | sha256sum | cut -d' ' -f1)
sed -i "s|sha256: .*|sha256: $SHA256|" clients/flatpak/com.gooseberrydevelopment.pinepods.yml
echo "Updating manifest for version: $VERSION"
# Show environment variables
echo "Using AMD64 SHA256: $AMD64_SHA256"
echo "Using ARM64 SHA256: $ARM64_SHA256"
# Update AMD64 entry first
sed -i "/.*amd64.deb/,/sha256:/ s|sha256: .*|sha256: $AMD64_SHA256|" com.gooseberrydevelopment.pinepods.yml
# Update ARM64 entry second
sed -i "/.*arm64.deb/,/sha256:/ s|sha256: .*|sha256: $ARM64_SHA256|" com.gooseberrydevelopment.pinepods.yml
# Update URLs
sed -i "s|url: .*amd64.deb|url: https://github.com/${{ github.repository }}/releases/download/$VERSION/Pinepods_${VERSION}_amd64.deb|" com.gooseberrydevelopment.pinepods.yml
sed -i "s|url: .*arm64.deb|url: https://github.com/${{ github.repository }}/releases/download/$VERSION/Pinepods_${VERSION}_arm64.deb|" com.gooseberrydevelopment.pinepods.yml
echo "Updated manifest content:"
cat com.gooseberrydevelopment.pinepods.yml
- name: Get shared Modules
run: |
Expand All @@ -49,7 +93,7 @@ jobs:
run: |
flatpak-builder --force-clean --sandbox --user --install-deps-from=flathub --ccache \
--mirror-screenshots-url=https://dl.flathub.org/media/ --repo=repo builddir \
clients/flatpak/com.gooseberrydevelopment.pinepods.yml
com.gooseberrydevelopment.pinepods.yml
flatpak remote-add --user --no-gpg-verify test-repo "$(pwd)/repo"
flatpak install --user -y test-repo ${{ env.FLATPAK_ID }}
Expand All @@ -70,8 +114,7 @@ jobs:
run: |
mkdir flatpak_output
cp ${{ env.FLATPAK_ID }}.flatpak flatpak_output/
cp clients/flatpak/com.gooseberrydevelopment.pinepods.yml flatpak_output/
cp clients/flatpak/${{ env.FLATPAK_ID }}.metainfo.xml flatpak_output/
cp com.gooseberrydevelopment.pinepods.yml flatpak_output/
tar -czvf flatpak_files.tar.gz flatpak_output
- name: Upload Flatpak archive
Expand Down
146 changes: 146 additions & 0 deletions clients/clientapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,152 @@ async def api_remove_category(data: RemoveCategoryData, cnx=Depends(get_database
raise HTTPException(status_code=403,
detail="Your API key is either invalid or does not have correct permission")

class TogglePodcastNotificationData(BaseModel):
user_id: int
podcast_id: int
enabled: bool

@app.put("/api/data/podcast/toggle_notifications")
async def api_toggle_podcast_notifications(
data: TogglePodcastNotificationData,
cnx=Depends(get_database_connection),
api_key: str = Depends(get_api_key_from_header)
):
is_valid_key = database_functions.functions.verify_api_key(cnx, database_type, api_key)
if not is_valid_key:
raise HTTPException(status_code=403, detail="Invalid API key")

is_web_key = api_key == base_webkey.web_key
key_id = database_functions.functions.id_from_api_key(cnx, database_type, api_key)

if key_id == data.user_id or is_web_key:
success = database_functions.functions.toggle_podcast_notifications(
cnx,
database_type,
data.podcast_id,
data.user_id,
data.enabled
)
if success:
return {"detail": "Podcast notification settings updated successfully"}
else:
raise HTTPException(status_code=400, detail="Error updating podcast notification settings")
else:
raise HTTPException(status_code=403, detail="You can only modify your own podcast settings")

class PodcastNotificationStatusData(BaseModel):
user_id: int
podcast_id: int

@app.post("/api/data/podcast/notification_status")
async def api_get_podcast_notification_status(
data: PodcastNotificationStatusData,
cnx=Depends(get_database_connection),
api_key: str = Depends(get_api_key_from_header)
):
is_valid_key = database_functions.functions.verify_api_key(cnx, database_type, api_key)
if not is_valid_key:
raise HTTPException(status_code=403, detail="Invalid API key")

is_web_key = api_key == base_webkey.web_key
key_id = database_functions.functions.id_from_api_key(cnx, database_type, api_key)

if key_id == data.user_id or is_web_key:
enabled = database_functions.functions.get_podcast_notification_status(
cnx,
database_type,
data.podcast_id,
data.user_id
)
return {"enabled": enabled}
else:
raise HTTPException(status_code=403, detail="You can only check your own podcast settings")

class NotificationSettingsData(BaseModel):
user_id: int
platform: str
enabled: bool
ntfy_topic: Optional[str]
ntfy_server_url: Optional[str]
gotify_url: Optional[str]
gotify_token: Optional[str]

@app.get("/api/data/user/notification_settings")
async def api_get_notification_settings(user_id: int, cnx=Depends(get_database_connection),
api_key: str = Depends(get_api_key_from_header)):
is_valid_key = database_functions.functions.verify_api_key(cnx, database_type, api_key)
if not is_valid_key:
raise HTTPException(status_code=403, detail="Invalid API key")

is_web_key = api_key == base_webkey.web_key
key_id = database_functions.functions.id_from_api_key(cnx, database_type, api_key)

if key_id == user_id or is_web_key:
settings = database_functions.functions.get_notification_settings(cnx, database_type, user_id)
return {"settings": settings}
else:
raise HTTPException(status_code=403, detail="You can only access your own notification settings")

@app.put("/api/data/user/notification_settings")
async def api_update_notification_settings(data: NotificationSettingsData, cnx=Depends(get_database_connection),
api_key: str = Depends(get_api_key_from_header)):
is_valid_key = database_functions.functions.verify_api_key(cnx, database_type, api_key)
if not is_valid_key:
raise HTTPException(status_code=403, detail="Invalid API key")

is_web_key = api_key == base_webkey.web_key
key_id = database_functions.functions.id_from_api_key(cnx, database_type, api_key)

if key_id == data.user_id or is_web_key:
success = database_functions.functions.update_notification_settings(
cnx,
database_type,
data.user_id,
data.platform,
data.enabled,
data.ntfy_topic,
data.ntfy_server_url,
data.gotify_url,
data.gotify_token
)
if success:
return {"detail": "Notification settings updated successfully"}
else:
raise HTTPException(status_code=400, detail="Error updating notification settings")
else:
raise HTTPException(status_code=403, detail="You can only modify your own notification settings")

class NotificationTestRequest(BaseModel):
user_id: int
platform: str

@app.post("/api/data/user/test_notification")
async def api_test_notification(
data: NotificationTestRequest,
cnx=Depends(get_database_connection),
api_key: str = Depends(get_api_key_from_header)
):
is_valid_key = database_functions.functions.verify_api_key(cnx, database_type, api_key)
if not is_valid_key:
raise HTTPException(status_code=403, detail="Invalid API key")

is_web_key = api_key == base_webkey.web_key
key_id = database_functions.functions.id_from_api_key(cnx, database_type, api_key)

if key_id == data.user_id or is_web_key:
success = database_functions.functions.send_test_notification(
cnx,
database_type,
data.user_id,
data.platform
)
if success:
return {"detail": "Test notification sent successfully"}
else:
raise HTTPException(status_code=400, detail="Error sending test notification")
else:
raise HTTPException(status_code=403, detail="You can only send test notifications to your own account")

class RecordListenDurationData(BaseModel):
episode_id: int
user_id: int
Expand Down
13 changes: 6 additions & 7 deletions completed_todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Next Minor Version:

- [] Ensure even when a podcast is clicked via the search page it still loads all the podcast db context
- [ ] Allow user to adjust amount of time to save/download youtube videos
- [ ] After adding podcast we no longer show dumpster
- [ ] Bad url while no channels added youtube

Version 0.7.3

- [ ] Youtube Subscriptions
- [x] Youtube Subscriptions
- [x] Fix refreshing so it handlees youtube subscriptions
- [x] Thumbnails for youtube episodes currently are just sections of the video
- [ ] Validate some more channel adds
- [x] Validate some more channel adds
- [x] Speed up channel add process by only checking recent videos up to 30 days.
- [x] When searching channels show more recent vids than just one
- [x] Dynamic updating youtube channels
- [x] Delete youtube subs
- [x] Ensure youtube videos update completion/listen time status correctly
- [x] check refreshing on episode/other youtube related pages
- [x] Make /episode page work with youtube
- [ ] Bad url while no channels added

- [x] Allowed and documented option to download episodes as specific user on host machine
- [x] Nextcloud Sync Fixed
- [x] Episode Completion Status is now pushed to Nextcloud/Gpodder
Expand All @@ -41,10 +41,9 @@ Version 0.7.3
- [x] Fix issue with episodes page opening when clicking show notes while on episodes page already
- [x] Fix issues with ability to open episode_layout page from episode page. That includes whether the podcast is added or not
- [x] Add podcastindexid to episode page url vars - Then pass to dynamic func call
- [ ] Validate Mysql functions
- [ ] Build clients and verify
- [x] Validate Mysql functions
- [x] Build clients and verify
- [x] Sometimes episodes are not even close to newest or right order in episode_layout
- [ ] After adding podcast we no longer show dumpster - screw that
- [x] Think the weird yt double refreshing after search is messing up which one is subbed to
- [x] Queuing yt ep also queues standard pod counterpart id

Expand Down
Loading

0 comments on commit 5f41489

Please sign in to comment.