-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route to change playlist description and add PlaylistsHelper
- Loading branch information
Showing
4 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package me.kavin.piped.utils; | ||
|
||
import org.hibernate.Session; | ||
|
||
import me.kavin.piped.utils.obj.db.User; | ||
|
||
public class PlaylistHelpers { | ||
public static PlaylistResult getUserPlaylist(Session s, User user, String playlistId) { | ||
var playlist = DatabaseHelper.getPlaylistFromId(s, playlistId); | ||
|
||
if (playlist == null) | ||
return new PlaylistResult(null, "Playlist not found"); | ||
|
||
if (playlist.getOwner().getId() != user.getId()) | ||
return new PlaylistResult(null, "You do not own this playlist"); | ||
|
||
return new PlaylistResult(playlist, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.kavin.piped.utils; | ||
|
||
import me.kavin.piped.utils.obj.db.Playlist; | ||
|
||
public final class PlaylistResult { | ||
private final Playlist playlist; | ||
private final String error; | ||
|
||
public PlaylistResult(Playlist playlist, String error) { | ||
this.playlist = playlist; | ||
this.error = error; | ||
} | ||
|
||
public Playlist getPlaylist() { | ||
return playlist; | ||
} | ||
|
||
public String getError() { | ||
return error; | ||
} | ||
} |