mirror of
https://github.com/krateng/maloja.git
synced 2025-04-15 16:30:32 +03:00
Add feedback for failed scrobble submission, fix GH-297
This commit is contained in:
parent
472281230c
commit
ea6e27de5c
@ -82,6 +82,14 @@ errors = {
|
||||
'desc':"This entity does not exist in the database."
|
||||
}
|
||||
}),
|
||||
database.exceptions.DuplicateTimestamp: lambda e: (409,{
|
||||
"status":"error",
|
||||
"error":{
|
||||
'type':'duplicate_timestamp',
|
||||
'value':e.rejected_scrobble,
|
||||
'desc':"A scrobble is already registered with this timestamp."
|
||||
}
|
||||
}),
|
||||
images.MalformedB64: lambda e: (400,{
|
||||
"status":"failure",
|
||||
"error":{
|
||||
|
@ -14,6 +14,13 @@ class ArtistExists(EntityExists):
|
||||
class AlbumExists(EntityExists):
|
||||
pass
|
||||
|
||||
|
||||
class DuplicateTimestamp(Exception):
|
||||
def __init__(self,existing_scrobble,rejected_scrobble):
|
||||
self.existing_scrobble = existing_scrobble
|
||||
self.rejected_scrobble = rejected_scrobble
|
||||
|
||||
|
||||
class DatabaseNotBuilt(HTTPError):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
|
@ -328,7 +328,10 @@ def album_dict_to_db(info,dbconn=None):
|
||||
|
||||
@connection_provider
|
||||
def add_scrobble(scrobbledict,update_album=False,dbconn=None):
|
||||
add_scrobbles([scrobbledict],update_album=update_album,dbconn=dbconn)
|
||||
_, e = add_scrobbles([scrobbledict],update_album=update_album,dbconn=dbconn)
|
||||
if e > 0:
|
||||
raise exc.DuplicateTimestamp(existing_scrobble=None,rejected_scrobble=scrobbledict)
|
||||
# TODO: actually pass existing scrobble
|
||||
|
||||
@connection_provider
|
||||
def add_scrobbles(scrobbleslist,update_album=False,dbconn=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user