diff --git a/backend/src/app/rpc/commands/files_branch.clj b/backend/src/app/rpc/commands/files_branch.clj index 3e813dba43..adcd9e006d 100644 --- a/backend/src/app/rpc/commands/files_branch.clj +++ b/backend/src/app/rpc/commands/files_branch.clj @@ -34,6 +34,7 @@ [app.features.fdata :as fdata] [app.features.file-snapshots :as fsnap] [app.features.logical-deletion :as ldel] + [app.jobs :as jobs] [app.loggers.audit :as-alias audit] [app.loggers.webhooks :as-alias webhooks] [app.msgbus :as mbus] @@ -49,7 +50,6 @@ [app.util.cache :as ucache] [app.util.pointer-map :as pmap] [app.util.services :as sv] - [app.worker :as wrk] [clojure.set :as set] [clojure.string :as str])) @@ -378,9 +378,9 @@ (close-branch-pull-requests! cfg id {:profile-id profile-id :status "closed" :deleted-at dt}) - (wrk/submit! {::db/conn conn - ::wrk/task :delete-object - ::wrk/params {:object :file :deleted-at dt :id branch-file-id}}) + (jobs/submit cfg + {::jobs/name :delete-object + ::jobs/params {:object :file :deleted-at dt :id branch-file-id}}) {:topic branch-file-id :message {:type :file-deleted :file-id branch-file-id diff --git a/backend/src/app/rpc/commands/files_pull_request.clj b/backend/src/app/rpc/commands/files_pull_request.clj index 9d2fc04040..40130ca84c 100644 --- a/backend/src/app/rpc/commands/files_pull_request.clj +++ b/backend/src/app/rpc/commands/files_pull_request.clj @@ -212,7 +212,7 @@ "Notify `reviewers` (profile ids) that `actor-id` requested their review on the pull request. Follows the same in-transaction outbox pattern as the comment emails." - [conn {:keys [title description] :as pr} {:keys [team-id actor-id branch-name target-name reviewers]}] + [{:keys [::db/conn] :as cfg} {:keys [title description] :as pr} {:keys [team-id actor-id branch-name target-name reviewers]}] (when (seq reviewers) (let [users (->> (teams/get-users+props conn team-id) (map profile/decode-row) @@ -222,8 +222,9 @@ url (format-pull-request-url pr team-id)] (doseq [reviewer-id reviewers] (when-let [{:keys [fullname email]} (get users reviewer-id)] - (eml/send! - {::eml/conn conn + (eml/send + cfg + {::eml/reuse-conn true ::eml/factory eml/review-request :public-uri (cf/get :public-uri) :to email @@ -349,7 +350,7 @@ :profile-id reviewer-id} {::db/return-keys false})) - (send-review-request-emails! conn + (send-review-request-emails! cfg {:id pr-id :source-file-id branch-file-id :title title @@ -596,7 +597,7 @@ cfg msgbus messages - (fn [{:keys [::db/conn]}] + (fn [{:keys [::db/conn] :as cfg}] (db/update! conn :file-pull-request (cond-> {:updated-at (ct/now)} (some? title) (assoc :title title) @@ -621,7 +622,7 @@ :profile-id reviewer-id})) (when (seq added) (let [row (db/exec-one! conn [sql:get-pull-request id])] - (send-review-request-emails! conn row + (send-review-request-emails! cfg row {:team-id team-id :actor-id profile-id :branch-name (:branch-name row) diff --git a/backend/test/backend_tests/branch_payload_writers_test.clj b/backend/test/backend_tests/branch_payload_writers_test.clj index 6aaaa60eaa..888085afdc 100644 --- a/backend/test/backend_tests/branch_payload_writers_test.clj +++ b/backend/test/backend_tests/branch_payload_writers_test.clj @@ -48,14 +48,16 @@ (th/db-query :file-data {:file-id file-id :type "main"})) (defn- scheduled-gc-file-ids - "The file ids of the `file-gc` tasks submitted so far." + "The file ids of the `file-gc` jobs submitted so far. A job's params + are plain JSON, so the id comes back as a string." [] - (->> (th/db-query :task {:name "file-gc"}) - (map (fn [{:keys [props]}] - (-> (if (db/pgobject? props) - (db/decode-transit-pgobject props) - props) - (get :file-id)))) + (->> (th/db-query :job {:name "file-gc"}) + (map (fn [{:keys [params]}] + (-> (if (db/pgobject? params) + (db/decode-json-pgobject params) + params) + (get :file-id) + (uuid/parse)))) (into #{}))) (defn- branch-row-id diff --git a/backend/test/backend_tests/rpc_file_pull_request_test.clj b/backend/test/backend_tests/rpc_file_pull_request_test.clj index 8ae0908c56..fc082eee7d 100644 --- a/backend/test/backend_tests/rpc_file_pull_request_test.clj +++ b/backend/test/backend_tests/rpc_file_pull_request_test.clj @@ -854,7 +854,7 @@ ;; that queueing fail after the pull request row is written (with-redefs [mbus/pub! (fn [_ & {:keys [message]}] (swap! seen conj message)) - eml/send! (fn [_] (throw (IllegalStateException. "boom")))] + eml/send (fn [_ _] (throw (IllegalStateException. "boom")))] (let [out (create-pr* author (:id branch) {:reviewers [(:id reviewer)]})] (t/is (some? (:error out))))) (t/is (empty? @seen))