From 2998fbd28a709aef09d228782ed0b1b90e86f807 Mon Sep 17 00:00:00 2001 From: gempir Date: Fri, 11 Nov 2022 21:25:37 +0100 Subject: [PATCH] correctly respond when user is banned or otherwise not available on api --- .github/workflows/ci.yml | 6 +----- api/server.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad2edb6..9841d4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,8 +41,4 @@ jobs: - name: Set outputs id: vars - run: echo "::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c1-4)" - - - name: announce update - run: | - echo -en "PASS ${{ secrets.TMI_TOKEN }}\r\nNICK gempbot\r\nPRIVMSG #pajlada :nymnREACT $(echo '${{ github.event.head_commit.message }}' | tr '\n' ' ' | cut -c -200) github.com/gempir/justlog/commit/${{ steps.vars.outputs.sha_short }} | justlog update\r\n" | openssl s_client -connect irc.chat.twitch.tv:6697 + run: echo "::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c1-4)" \ No newline at end of file diff --git a/api/server.go b/api/server.go index 76e6865..253e067 100644 --- a/api/server.go +++ b/api/server.go @@ -171,6 +171,11 @@ func (s *Server) fillUserids(w http.ResponseWriter, r *http.Request) (url.Values http.Error(w, err.Error(), http.StatusInternalServerError) return nil, err } + if len(users) == 0 { + err := fmt.Errorf("could not find users") + http.Error(w, err.Error(), http.StatusUnprocessableEntity) + return nil, err + } query.Set("userid", users[username].ID) } @@ -183,6 +188,11 @@ func (s *Server) fillUserids(w http.ResponseWriter, r *http.Request) (url.Values http.Error(w, err.Error(), http.StatusInternalServerError) return nil, err } + if len(users) == 0 { + err := fmt.Errorf("could not find users") + http.Error(w, err.Error(), http.StatusUnprocessableEntity) + return nil, err + } query.Set("channelid", users[channelName].ID) }