vrious fixes
This commit is contained in:
parent
3d3a0dc789
commit
12ffaa4fc8
|
@ -76,11 +76,13 @@ class PrivacyLevelPermission(BasePermission):
|
|||
# to avoid leaking data (#2326)
|
||||
return True
|
||||
|
||||
privacy_level = (
|
||||
obj.actor.user.privacy_level
|
||||
if hasattr(obj, "actor")
|
||||
else obj.user.privacy_level
|
||||
)
|
||||
if hasattr(obj, "privacy_level"):
|
||||
privacy_level = obj.privacy_level
|
||||
elif hasattr(obj, "actor") and obj.actor.user:
|
||||
privacy_level = obj.actor.user.privacy_level
|
||||
else:
|
||||
privacy_level = obj.user.privacy_level
|
||||
|
||||
obj_actor = obj.actor if hasattr(obj, "actor") else obj.user.actor
|
||||
|
||||
if privacy_level == "everyone":
|
||||
|
|
|
@ -67,11 +67,21 @@ class PlaylistSerializer(serializers.ModelSerializer):
|
|||
|
||||
@extend_schema_field(OpenApiTypes.BOOL)
|
||||
def get_library_followed(self, obj):
|
||||
if lib_follow := obj.library.received_follows.filter(
|
||||
actor=self.context["request"].user.actor
|
||||
if self.context.get("request", False) and hasattr(
|
||||
self.context["request"], "user"
|
||||
):
|
||||
return lib_follow.approved
|
||||
actor = self.context["request"].user.actor
|
||||
lib_qs = obj.library.received_follows.filter(actor=actor)
|
||||
logger.info(f"lib_qs is {str(lib_qs)}")
|
||||
|
||||
if lib_qs.exists():
|
||||
logger.info(f"lib_qs exiiiiiist {str(lib_qs[0].approved)}")
|
||||
if lib_qs[0].approved is None:
|
||||
return False
|
||||
else:
|
||||
return lib_qs[0].approved
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@extend_schema_field(OpenApiTypes.BOOL)
|
||||
|
|
|
@ -88,6 +88,7 @@ def test_playlist_serializer(factories, to_api_date):
|
|||
"album_covers": [],
|
||||
"description": playlist.description,
|
||||
"library": playlist.library.fid,
|
||||
"library_followed": None,
|
||||
}
|
||||
serializer = serializers.PlaylistSerializer(playlist)
|
||||
|
||||
|
|
|
@ -100,9 +100,9 @@ const labels = computed(() => ({
|
|||
: props.playlist
|
||||
? t('components.audio.PlayButton.button.playPlaylist')
|
||||
: t('components.audio.PlayButton.button.playTracks'),
|
||||
PlaylistUploadAlreadyFollowed: t('components.audio.PlayButton.button.playPlaylist'),
|
||||
PlaylistUploadGranted: t('components.audio.PlayButton.button.PlaylistUploadGranted'),
|
||||
PlaylistUploadPending:t('components.audio.PlayButton.button.PlaylistUploadPending'),
|
||||
PlaylistUploadAccess: t('components.audio.PlayButton.button.PlaylistUploadAccess'),
|
||||
PlaylistUploadNotRequest: t('components.audio.PlayButton.button.PlaylistUploadNotRequest'),
|
||||
PlaylistUploadTooltip: t('components.audio.PlayButton.button.PlaylistUploadTooltip')
|
||||
}))
|
||||
|
||||
|
@ -116,7 +116,7 @@ const playlistFollowInfo = computed(() => {
|
|||
|
||||
if (followed === true) {
|
||||
return {
|
||||
label: labels.value.PlaylistUploadAlreadyFollowed,
|
||||
label: labels.value.PlaylistUploadGranted,
|
||||
tooltip: labels.value.PlaylistUploadTooltip,
|
||||
icon: 'bi-check-circle',
|
||||
disabled: true
|
||||
|
@ -134,12 +134,12 @@ const playlistFollowInfo = computed(() => {
|
|||
|
||||
// Assume null/undefined means not yet requested
|
||||
return {
|
||||
label: labels.value.PlaylistUploadAccess,
|
||||
label: labels.value.PlaylistUploadNotRequest,
|
||||
tooltip: labels.value.PlaylistUploadTooltip,
|
||||
icon: 'bi-eye-slash',
|
||||
disabled: false,
|
||||
action: requestPlaylistUploadsAccess
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -272,7 +272,7 @@ const playlistFollowInfo = computed(() => {
|
|||
:title="playlistFollowInfo.tooltip"
|
||||
:icon="playlistFollowInfo.icon"
|
||||
:disabled="playlistFollowInfo.disabled"
|
||||
@click.stop.prevent="playlistFollowInfo.action "
|
||||
@click.stop.prevent="requestPlaylistUploadsAccess(playlist)"
|
||||
>
|
||||
{{ playlistFollowInfo.label }}
|
||||
</PopoverItem>
|
||||
|
|
|
@ -201,13 +201,28 @@ export default (props: PlayOptionsProps) => {
|
|||
}
|
||||
|
||||
const requestPlaylistUploadsAccess = async (playlist: Playlist) => {
|
||||
const libresponse = await axios.get(props.playlist?.library)
|
||||
const response = await axios.post('federation/follows/library', {
|
||||
params: { target: libresponse.data.results.uuid }
|
||||
});
|
||||
const libraryUrl = playlist.library;
|
||||
if (!libraryUrl) {
|
||||
throw new Error("Playlist library URL is missing.");
|
||||
}
|
||||
const libResponse = await axios.get(libraryUrl);
|
||||
const id = libResponse.data?.id || libResponse.data?.results?.id;
|
||||
if (!id) {
|
||||
throw new Error("Library id not found in response.");
|
||||
}
|
||||
const fetchResponse = await axios.post('federation/fetches',
|
||||
{ object: id }
|
||||
);
|
||||
|
||||
const response = await axios.post(
|
||||
'federation/follows/library',
|
||||
{ target: fetchResponse.data.object.uuid }
|
||||
);
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
playable,
|
||||
filterableArtist,
|
||||
|
|
|
@ -483,10 +483,10 @@
|
|||
"playArtist": "Play artist",
|
||||
"playNext": "Play next",
|
||||
"playNow": "Play now",
|
||||
"PlaylistUploadAlreadyFollowed": "The owner of the playlist granted you access to his playlist's files",
|
||||
"PlaylistUploadGranted": "The owner of the playlist granted you access to his playlist's files",
|
||||
"PlaylistUploadTooltip": "This only applies to files owned by the playlist actor. If you want to get access to all the files, think to buy them to support your favorites artists",
|
||||
"PlaylistUploadPending": "You've already requested access to the playlist files",
|
||||
"PlaylistUploadAccess": "Request access to the files from this playlist",
|
||||
"PlaylistUploadNotRequest": "Request access to the files from this playlist",
|
||||
"playPlaylist": "Play playlist",
|
||||
"playTrack": "Play track",
|
||||
"playTracks": "Play tracks",
|
||||
|
|
Loading…
Reference in New Issue