Add double star for Purple members that have been active for over a year

This commit adds a special badge for purple members who have been active
for more than one entire year.

Closes: https://github.com/damus-io/damus/issues/2831
Changelog-Added: Purple members who have been active for more than a year now get a special badge
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-01-29 16:33:22 -08:00
parent 72c19fc411
commit 79407f17e8
3 changed files with 181 additions and 11 deletions
+14 -1
View File
@@ -418,6 +418,13 @@ class DamusPurple: StoreObserverDelegate {
let expiry: Date
let subscriber_number: Int
let active: Bool
let attributes: PurpleAccountAttributes
struct PurpleAccountAttributes: OptionSet {
let rawValue: Int
static let memberForMoreThanOneYear = PurpleAccountAttributes(rawValue: 1 << 0)
}
func ordinal() -> String? {
let number = Int(self.subscriber_number)
@@ -438,7 +445,8 @@ class DamusPurple: StoreObserverDelegate {
created_at: Date.init(timeIntervalSince1970: TimeInterval(payload.created_at)),
expiry: Date.init(timeIntervalSince1970: TimeInterval(payload.expiry)),
subscriber_number: Int(payload.subscriber_number),
active: payload.active
active: payload.active,
attributes: (payload.attributes?.member_for_more_than_one_year ?? false) ? [.memberForMoreThanOneYear] : []
)
}
@@ -448,6 +456,11 @@ class DamusPurple: StoreObserverDelegate {
let expiry: UInt64 // Unix timestamp
let subscriber_number: UInt
let active: Bool
let attributes: Attributes?
struct Attributes: Codable {
let member_for_more_than_one_year: Bool
}
}
}
}