(request: WSGIRequest)
return HttpResponse()
Modify the vote-count of the given song by the given amount.
    If a song receives too many downvotes, it is removed.
Modify the vote-count of the given song by the given amount.
    If a song receives too many downvotes, it is removed.
Modify the vote - count of the given song by the given amount . If a song receives too many downvotes it is removed .
def vote(request: WSGIRequest) -> HttpResponse:
    """Modify the vote-count of the given song by the given amount.
    If a song receives too many downvotes, it is removed."""
    key = request.POST.get("key")
    amount = request.POST.get("amount")
    if key is None or amount is None:
        return HttpResponseBadRequest()
    ikey = int(key)
    amount = int(amount)
    if amount < -2 or amount > 2:
        return HttpResponseBadRequest()

    if storage.get("ip_checking") and not user_manager.try_vote(
        user_manager.get_client_ip(request), ikey, amount
    ):
        return HttpResponseBadRequest("nice try")

    models.CurrentSong.objects.filter(queue_key=ikey).update(votes=F("votes") + amount)
    try:
        current_song = models.CurrentSong.objects.get()
        if current_song.queue_key == ikey and current_song.votes <= -storage.get(
            "downvotes_to_kick"
        ):
            with playback.mopidy_command() as allowed:
                if allowed:
                    player.playback.next()
    except models.CurrentSong.DoesNotExist:
        pass

    removed = playback.queue.vote(ikey, amount, -storage.get("downvotes_to_kick"))
    # if we removed a song by voting, and it was added by autoplay,
    # we want it to be the new basis for autoplay
    if removed is not None:
        if not removed.manually_requested:
            playback.handle_autoplay(removed.external_url or removed.title)
        else:
            playback.handle_autoplay()
    musiq.update_state()
    return HttpResponse()
def vote ( request : WSGIRequest ) -> HttpResponse : key = request . POST . get ( "key" ) amount = request . POST . get ( "amount" ) if key is None or amount is None : return HttpResponseBadRequest ( ) ikey = int ( key ) amount = int ( amount ) if amount < - 2 or amount > 2 : return HttpResponseBadRequest ( ) if storage . get ( "ip_checking" ) and not user_manager . try_vote ( user_manager . get_client_ip ( request ) , ikey , amount ) : return HttpResponseBadRequest ( "nice try" ) models . CurrentSong . objects . filter ( queue_key = ikey ) . update ( votes = F ( "votes" ) + amount ) try : current_song = models . CurrentSong . objects . get ( ) if current_song . queue_key == ikey and current_song . votes <= - storage . get ( "downvotes_to_kick" ) : with playback . mopidy_command ( ) as allowed : if allowed : player . playback . next ( ) except models . CurrentSong . DoesNotExist : pass removed = playback . queue . vote ( ikey , amount , - storage . get ( "downvotes_to_kick" ) ) # if we removed a song by voting, and it was added by autoplay, # we want it to be the new basis for autoplay if removed is not None : if not removed . manually_requested : playback . handle_autoplay ( removed . external_url or removed . title ) else : playback . handle_autoplay ( ) musiq . update_state ( ) return HttpResponse ( )