Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
Merge branch 'mainline' into block-kit-accessory
Browse files Browse the repository at this point in the history
  • Loading branch information
belucid committed Apr 10, 2019
2 parents 5ce2daa + 1093b53 commit 625f4f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
12 changes: 6 additions & 6 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject open-company/lib "0.17.3-alpha9"
(defproject open-company/lib "0.17.5-alpha1"
:description "OpenCompany Common Library"
:url "https://github.com/open-company/open-company-lib"
:license {
Expand All @@ -18,7 +18,7 @@
;; Async programming and communication https://github.com/clojure/core.async
[org.clojure/core.async "0.4.490"]
;; Erlang-esque pattern matching https://github.com/clojure/core.match
[org.clojure/core.match "0.3.0-alpha5"]
[org.clojure/core.match "0.3.0"]
;; Clojure reader https://github.com/clojure/tools.reader
;; NB: Not used directly, but a very common dependency, so pulled in for manual version management
[org.clojure/tools.reader "1.3.2"]
Expand Down Expand Up @@ -73,7 +73,7 @@
[amazonica "0.3.141"
:exclusions [joda-time commons-logging commons-codec com.fasterxml.jackson.core/jackson-databind com.amazonaws/aws-java-sdk-dynamodb]]
;; DynamoDB SDK
[com.amazonaws/aws-java-sdk-dynamodb "1.11.525"]
[com.amazonaws/aws-java-sdk-dynamodb "1.11.534"]
;; Data binding and tree for XML https://github.com/FasterXML/jackson-databind
;; NB: Not used directly, but a very common dependency, so pulled in for manual version management
[com.fasterxml.jackson.core/jackson-databind "2.9.8"]
Expand Down Expand Up @@ -104,7 +104,7 @@
;; HTTP client https://github.com/dakrone/clj-http
[clj-http "3.9.1"]
;; String manipulation library https://github.com/funcool/cuerdas
[funcool/cuerdas "2.1.0"]
[funcool/cuerdas "2.2.0"]
]

:profiles {
Expand All @@ -117,7 +117,7 @@
;; NB: clj-time is pulled in manually
;; NB: joda-time is pulled in by clj-time
;; NB: commons-codec pulled in manually
[midje "1.9.6" :exclusions [joda-time org.clojure/tools.macro clj-time commons-codec]]
[midje "1.9.8" :exclusions [joda-time org.clojure/tools.macro clj-time commons-codec]]
]
:plugins [
;; Example-based testing https://github.com/marick/lein-midje
Expand Down Expand Up @@ -146,7 +146,7 @@
;; Dead code finder (use carefully, false positives) https://github.com/venantius/yagni
[venantius/yagni "0.1.7" :exclusions [org.clojure/clojure]]
;; Autotest https://github.com/jakemcc/lein-test-refresh
[com.jakemccrary/lein-test-refresh "0.24.0"]
[com.jakemccrary/lein-test-refresh "0.24.1"]
]
}]

Expand Down
27 changes: 21 additions & 6 deletions src/oc/lib/slack.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,34 @@
[text]
(str marker-char text))

(defn report-slack-error [body e]
(timbre/info "Error parsing Slack response" body)
(timbre/error e)
(throw e))

(defn slack-api [method params]
(timbre/info "Making slack request:" method)
(let [url (str "https://slack.com/api/" (name method))
{:keys [status headers body error] :as resp} @(http/get url {:query-params params :as :text})]
(if error
(throw (ex-info "Error from Slack API"
{:method method
:params params
:status status
:body body}))
(report-slack-error body (ex-info "Error from Slack API"
{:method method
:params params
:status status
:body body}))
(do
(timbre/trace "Slack response:" body)
(-> body json/decode keywordize-keys)))))
(try
(let [response-body (-> body json/decode keywordize-keys)]
(if-not (:ok response-body)
(report-slack-error body (ex-info "Slack request was rejected"
{:body body
:status status
:method method
:params params}))
response-body))
(catch com.fasterxml.jackson.core.JsonParseException e
(report-slack-error body e)))))))

(defn get-team-info [token]
(:team (slack-api :team.info {:token token})))
Expand Down
8 changes: 4 additions & 4 deletions src/oc/lib/user_avatar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"
First it fixes relative URLs, it prepends our production CDN domain to it if it's relative.
Then if the url is pointing to one of our happy faces, it replaces the SVG extension with PNG
to have it resizable. If it's not one of our happy faces, it uses the on-the-fly resize url."
to have it resizable. If it's not one of our happy faces, it uses the on-the-fly resize url.
"
[filestack-api-key avatar-url]
(let [absolute-avatar-url (if (s/starts-with? avatar-url "/img")
(str "https://d1wc0stj82keig.cloudfront.net" avatar-url)
avatar-url)
r (re-seq #"happy_face_(red|green|blue|purple|yellow).svg$" absolute-avatar-url)]
(if r
avatar-url)]
(if (re-seq #"happy_face_(red|green|blue|purple|yellow).svg$" absolute-avatar-url) ; carrot default?
(str (subs absolute-avatar-url 0 (- (count absolute-avatar-url) 3)) "png")
(circle-image filestack-api-key absolute-avatar-url 32))))

0 comments on commit 625f4f9

Please sign in to comment.