diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 03b071b..bdd2a98 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -428,6 +428,12 @@ UPDATE issues SET is_open = :is_open WHERE issue_id = :issue_id; +-- :name reset-bot-confirmation :! :n +-- :doc updates issue's execute and confirm hash +UPDATE issues +SET execute_hash = NULL, +confirm_hash = NULL +WHERE issue_id = :issue_id; -- :name issue-exists :1 -- :doc returns true if given issue exists diff --git a/src/clj/commiteth/db/issues.clj b/src/clj/commiteth/db/issues.clj index d103093..91e33b8 100644 --- a/src/clj/commiteth/db/issues.clj +++ b/src/clj/commiteth/db/issues.clj @@ -95,6 +95,12 @@ (db/update-issue-open con-db {:issue_id issue-id :is_open is-open}))) +(defn reset-bot-confirmation + "resets execute and confirm hash to null for given issue id" + [issue-id] + (jdbc/with-db-connection [con-db *db*] + (db/reset-bot-confirmation con-db {:issue_id issue-id}))) + (defn is-bounty-issue? [issue-id] (let [res (jdbc/with-db-connection [con-db *db*] diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index eeef6ac..f6bb94a 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -266,4 +266,12 @@ (ok {:issue-id issue-id :execute-hash execute-hash :contract-address contract-address}) - (bad-request (str "Unable to withdraw funds from " contract-address))))))))) + (bad-request (str "Unable to withdraw funds from " contract-address)))))) + (POST "/remove-bot-confirmation" {{issue-id :issue-id} :params} + :auth-rules authenticated? + :current-user user + (do (log/infof "calling remove-bot-confirmation for %s " issue-id) + ;; if this resulted in updating a row, return success + (if (pos? (issues/reset-bot-confirmation issue-id)) + (ok (str "Updated execute and confirm hash for " issue-id)) + (bad-request (str "Unable to update execute and confirm hash for " issue-id))))))))