@@ -130,6 +130,13 @@ class PlaylistActionsImpl(val yandexMusic: YandexMusic, val messageSource: Messa
130130 }
131131
132132 override fun playlist (userId : Long , chatId : String , callback : PlaylistCallback ): ResultOf <SendMessage > {
133+ userStorage.getUserStorageData(userId).isDownloadProcess {
134+ return ResultOf .Failure (
135+ ErrorBuilder .newBuilder(ErrorKind .APP_INTERNAL )
136+ .withCode(403 )
137+ .withDescription(messageSource.getMessage(" errors.latest.playlists.position.using" , null , Locale .getDefault())))
138+ }
139+
133140 val playlistResult = yandexMusic.getPlaylist(callback.kind, callback.owner)
134141 playlistResult.returnNok { return it }
135142 val playlist = (playlistResult as ResultOf .Success ).value
@@ -151,6 +158,13 @@ class PlaylistActionsImpl(val yandexMusic: YandexMusic, val messageSource: Messa
151158 * Daily playlist for current yandex user
152159 * */
153160 override fun dailyPlaylist (userId : Long , chatId : String ): ResultOf <SendMessage > {
161+ userStorage.getUserStorageData(userId).isDownloadProcess {
162+ return ResultOf .Failure (
163+ ErrorBuilder .newBuilder(ErrorKind .APP_INTERNAL )
164+ .withCode(403 )
165+ .withDescription(messageSource.getMessage(" errors.latest.playlists.position.using" , null , Locale .getDefault())))
166+ }
167+
154168 val dailyIdResult = yandexMusic.getPlaylists()
155169 dailyIdResult.returnNok { return it }
156170 val dailyPlaylists = (dailyIdResult as ResultOf .Success ).value
@@ -180,6 +194,13 @@ class PlaylistActionsImpl(val yandexMusic: YandexMusic, val messageSource: Messa
180194 * Show search tracks to user
181195 * */
182196 override fun searchByString (userId : Long , chatId : String , text : String ): ResultOf <SendMessage > {
197+ userStorage.getUserStorageData(userId).isDownloadProcess {
198+ return ResultOf .Failure (
199+ ErrorBuilder .newBuilder(ErrorKind .APP_INTERNAL )
200+ .withCode(403 )
201+ .withDescription(messageSource.getMessage(" errors.latest.playlists.position.using" , null , Locale .getDefault())))
202+ }
203+
183204 // TODO cut string to limit
184205 val searchText = URLEncoder .encode(text.trimIndent(), " utf-8" )
185206 val searchResult = yandexMusic.search(searchText)
@@ -209,6 +230,13 @@ class PlaylistActionsImpl(val yandexMusic: YandexMusic, val messageSource: Messa
209230 * Limit for json, when more than 150 we should request by ids
210231 * */
211232 override fun artistWithPagesMsg (userId : Long , chatId : String , callback : ArtistTrackWithPagesCallback ): ResultOf <SendMessage > {
233+ userStorage.getUserStorageData(userId).isDownloadProcess {
234+ return ResultOf .Failure (
235+ ErrorBuilder .newBuilder(ErrorKind .APP_INTERNAL )
236+ .withCode(403 )
237+ .withDescription(messageSource.getMessage(" errors.latest.playlists.position.using" , null , Locale .getDefault())))
238+ }
239+
212240 val page = callback.page
213241 val searchResult = yandexMusic.searchTrack(callback.artistId)
214242 searchResult.returnNok { return it }
@@ -237,6 +265,13 @@ class PlaylistActionsImpl(val yandexMusic: YandexMusic, val messageSource: Messa
237265 * Pagination for searched tracks
238266 * */
239267 override fun searchWithPagesMsg (userId : Long , chatId : String , callback : SearchTrackWithPagesCallback ): ResultOf <SendMessage > {
268+ userStorage.getUserStorageData(userId).isDownloadProcess {
269+ return ResultOf .Failure (
270+ ErrorBuilder .newBuilder(ErrorKind .APP_INTERNAL )
271+ .withCode(403 )
272+ .withDescription(messageSource.getMessage(" errors.latest.playlists.position.using" , null , Locale .getDefault())))
273+ }
274+
240275 // logger.info("searchWithPagesMsg callback = {}", callback)
241276 val page = callback.page
242277 val realPageForRequest = ((page - 1 ) * TRACKS_PER_PAGE ) / 100
0 commit comments