vrious fixes
This commit is contained in:
parent
3d3a0dc789
commit
12ffaa4fc8
|
@ -76,11 +76,13 @@ class PrivacyLevelPermission(BasePermission):
|
||||||
# to avoid leaking data (#2326)
|
# to avoid leaking data (#2326)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
privacy_level = (
|
if hasattr(obj, "privacy_level"):
|
||||||
obj.actor.user.privacy_level
|
privacy_level = obj.privacy_level
|
||||||
if hasattr(obj, "actor")
|
elif hasattr(obj, "actor") and obj.actor.user:
|
||||||
else obj.user.privacy_level
|
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
|
obj_actor = obj.actor if hasattr(obj, "actor") else obj.user.actor
|
||||||
|
|
||||||
if privacy_level == "everyone":
|
if privacy_level == "everyone":
|
||||||
|
|
|
@ -67,11 +67,21 @@ class PlaylistSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
@extend_schema_field(OpenApiTypes.BOOL)
|
@extend_schema_field(OpenApiTypes.BOOL)
|
||||||
def get_library_followed(self, obj):
|
def get_library_followed(self, obj):
|
||||||
if lib_follow := obj.library.received_follows.filter(
|
if self.context.get("request", False) and hasattr(
|
||||||
actor=self.context["request"].user.actor
|
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:
|
else:
|
||||||
|
return lib_qs[0].approved
|
||||||
|
else:
|
||||||
|
return None
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@extend_schema_field(OpenApiTypes.BOOL)
|
@extend_schema_field(OpenApiTypes.BOOL)
|
||||||
|
|
|
@ -88,6 +88,7 @@ def test_playlist_serializer(factories, to_api_date):
|
||||||
"album_covers": [],
|
"album_covers": [],
|
||||||
"description": playlist.description,
|
"description": playlist.description,
|
||||||
"library": playlist.library.fid,
|
"library": playlist.library.fid,
|
||||||
|
"library_followed": None,
|
||||||
}
|
}
|
||||||
serializer = serializers.PlaylistSerializer(playlist)
|
serializer = serializers.PlaylistSerializer(playlist)
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,9 @@ const labels = computed(() => ({
|
||||||
: props.playlist
|
: props.playlist
|
||||||
? t('components.audio.PlayButton.button.playPlaylist')
|
? t('components.audio.PlayButton.button.playPlaylist')
|
||||||
: t('components.audio.PlayButton.button.playTracks'),
|
: 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'),
|
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')
|
PlaylistUploadTooltip: t('components.audio.PlayButton.button.PlaylistUploadTooltip')
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ const playlistFollowInfo = computed(() => {
|
||||||
|
|
||||||
if (followed === true) {
|
if (followed === true) {
|
||||||
return {
|
return {
|
||||||
label: labels.value.PlaylistUploadAlreadyFollowed,
|
label: labels.value.PlaylistUploadGranted,
|
||||||
tooltip: labels.value.PlaylistUploadTooltip,
|
tooltip: labels.value.PlaylistUploadTooltip,
|
||||||
icon: 'bi-check-circle',
|
icon: 'bi-check-circle',
|
||||||
disabled: true
|
disabled: true
|
||||||
|
@ -134,12 +134,12 @@ const playlistFollowInfo = computed(() => {
|
||||||
|
|
||||||
// Assume null/undefined means not yet requested
|
// Assume null/undefined means not yet requested
|
||||||
return {
|
return {
|
||||||
label: labels.value.PlaylistUploadAccess,
|
label: labels.value.PlaylistUploadNotRequest,
|
||||||
tooltip: labels.value.PlaylistUploadTooltip,
|
tooltip: labels.value.PlaylistUploadTooltip,
|
||||||
icon: 'bi-eye-slash',
|
icon: 'bi-eye-slash',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
action: requestPlaylistUploadsAccess
|
action: requestPlaylistUploadsAccess
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ const playlistFollowInfo = computed(() => {
|
||||||
:title="playlistFollowInfo.tooltip"
|
:title="playlistFollowInfo.tooltip"
|
||||||
:icon="playlistFollowInfo.icon"
|
:icon="playlistFollowInfo.icon"
|
||||||
:disabled="playlistFollowInfo.disabled"
|
:disabled="playlistFollowInfo.disabled"
|
||||||
@click.stop.prevent="playlistFollowInfo.action "
|
@click.stop.prevent="requestPlaylistUploadsAccess(playlist)"
|
||||||
>
|
>
|
||||||
{{ playlistFollowInfo.label }}
|
{{ playlistFollowInfo.label }}
|
||||||
</PopoverItem>
|
</PopoverItem>
|
||||||
|
|
|
@ -201,13 +201,28 @@ export default (props: PlayOptionsProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestPlaylistUploadsAccess = async (playlist: Playlist) => {
|
const requestPlaylistUploadsAccess = async (playlist: Playlist) => {
|
||||||
const libresponse = await axios.get(props.playlist?.library)
|
const libraryUrl = playlist.library;
|
||||||
const response = await axios.post('federation/follows/library', {
|
if (!libraryUrl) {
|
||||||
params: { target: libresponse.data.results.uuid }
|
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 response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playable,
|
playable,
|
||||||
filterableArtist,
|
filterableArtist,
|
||||||
|
|
|
@ -483,10 +483,10 @@
|
||||||
"playArtist": "Play artist",
|
"playArtist": "Play artist",
|
||||||
"playNext": "Play next",
|
"playNext": "Play next",
|
||||||
"playNow": "Play now",
|
"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",
|
"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",
|
"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",
|
"playPlaylist": "Play playlist",
|
||||||
"playTrack": "Play track",
|
"playTrack": "Play track",
|
||||||
"playTracks": "Play tracks",
|
"playTracks": "Play tracks",
|
||||||
|
|
Loading…
Reference in New Issue