Skip to content

Commit

Permalink
Use global update check for Slack
Browse files Browse the repository at this point in the history
Supports both .dmg install and App store install.

Closes #80
  • Loading branch information
dz0ny committed Dec 16, 2021
1 parent b6825c6 commit 26f5444
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Pareto/Checks/Software Updates/Slack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// Created by Janez Troha on 11/11/2021.
//

import Alamofire
import os.log
import Regex

class AppSlackCheck: AppCheck {
static let sharedInstance = AppSlackCheck()

Expand All @@ -15,4 +19,22 @@ class AppSlackCheck: AppCheck {
override var UUID: String {
"9894a05b-964d-5c19-bef7-53112207d271"
}

override func getLatestVersion(completion: @escaping (String) -> Void) {
let url = "https://slack.com/release-notes/mac"
let versionRegex = Regex("<h2>Slack ?([\\.\\d]+)</h2>")
os_log("Requesting %{public}s", url)
AF.request(url).responseString(queue: AppCheck.queue, completionHandler: { response in
if response.error == nil {
let html = response.value ?? "<h2>Slack 1.23.0</h2>"
let version = versionRegex.firstMatch(in: html)?.groups.first?.value ?? "1.23.0"
os_log("%{public}s version=%{public}s", self.appBundle, version)
completion(version)
} else {
os_log("%{public}s failed: %{public}s", self.appBundle, response.error.debugDescription)
completion("0.0.0")
}

})
}
}
2 changes: 1 addition & 1 deletion Pareto/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>3666</string>
<string>3668</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 26f5444

Please sign in to comment.