Skip to content

Commit aa8bd19

Browse files
committed
* fix for unverified commits
1 parent 7685aac commit aa8bd19

2 files changed

Lines changed: 40 additions & 5 deletions

File tree

GitHubListener/AppDelegate.swift

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCent
202202
for commit in commits.reversed() {
203203
let testDate:Date = commit.description.author.date
204204
if (date != nil && date != testDate) {
205-
self.showNotification(title: "\(repo.name)", subtitle: "\(commit.author.login) added commit", informativeText: commit.description.message, image: commit.author.avatarUrl, url: commit.htmlUrl)
205+
if (commit.description.verification.verified) {
206+
self.showNotification(title: "\(repo.name)", subtitle: "\(commit.author.login) added commit", informativeText: commit.description.message, image: commit.author.avatarUrl, url: commit.htmlUrl)
207+
} else {
208+
self.showNotification(title: "\(repo.name)", subtitle: "\(commit.description.author.name) added commit", informativeText: commit.description.message, url: commit.htmlUrl)
209+
}
206210
}
207211
}
208212
}
@@ -526,7 +530,12 @@ struct Commit: Codable {
526530
let container = try decoder.container(keyedBy: CodingKeys.self)
527531
let id = try container.decode(String.self, forKey: .id)
528532
let htmlUrl = try container.decode(String.self, forKey: .htmlUrl)
529-
let author = try container.decode(User.self, forKey: .author)
533+
var author:User = User(id: 0, login: "", avatarUrl: "")
534+
do {
535+
author = try container.decode(User.self, forKey: .author)
536+
} catch {
537+
538+
}
530539
let description = try container.decode(CommitDescription.self, forKey: .description)
531540
self.init(id: id, htmlUrl: htmlUrl, author: author, description: description)
532541
}
@@ -563,25 +572,29 @@ struct Commit: Codable {
563572
let message: String
564573
let commentCount: Int
565574
let author: CommitAuthor
575+
let verification: Verification
566576

567577
enum CodingKeys: String, CodingKey {
568578
case message
569579
case commentCount = "comment_count"
570580
case author
581+
case verification
571582
}
572583

573-
init(message: String, commentCount: Int, author: CommitAuthor) {
584+
init(message: String, commentCount: Int, author: CommitAuthor, verification: Verification) {
574585
self.message = message
575586
self.commentCount = commentCount
576587
self.author = author
588+
self.verification = verification
577589
}
578590

579591
init(from decoder: Decoder) throws {
580592
let container = try decoder.container(keyedBy: CodingKeys.self)
581593
let message = try container.decode(String.self, forKey: .message)
582594
let commentCount = try container.decode(Int.self, forKey: .commentCount)
583595
let author = try container.decode(CommitAuthor.self, forKey: .author)
584-
self.init(message: message, commentCount: commentCount, author: author)
596+
let verification = try container.decode(Verification.self, forKey: .verification)
597+
self.init(message: message, commentCount: commentCount, author: author, verification: verification)
585598
}
586599

587600
struct CommitAuthor: Codable {
@@ -609,6 +622,28 @@ struct Commit: Codable {
609622
self.init(name: name, email: email, date: date)
610623
}
611624
}
625+
626+
struct Verification: Codable {
627+
let verified: Bool
628+
let reason: String
629+
630+
enum CodingKeys: String, CodingKey {
631+
case verified
632+
case reason
633+
}
634+
635+
init(verified: Bool, reason: String) {
636+
self.verified = verified
637+
self.reason = reason
638+
}
639+
640+
init(from decoder: Decoder) throws {
641+
let container = try decoder.container(keyedBy: CodingKeys.self)
642+
let verified = try container.decode(Bool.self, forKey: .verified)
643+
let reason = try container.decode(String.self, forKey: .reason)
644+
self.init(verified: verified, reason: reason)
645+
}
646+
}
612647
}
613648
}
614649

GitHubListener/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
20+
<string>0.3</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
2323
<key>LSApplicationCategoryType</key>

0 commit comments

Comments
 (0)