FollowPackEvent.swift (1264B)
1 // 2 // FollowPackEvent.swift 3 // damus 4 // 5 // Created by eric on 4/30/25. 6 // 7 8 9 import Foundation 10 11 struct FollowPackEvent: Hashable { 12 let event: NostrEvent 13 var title: String? = nil 14 var uuid: String? = nil 15 var image: URL? = nil 16 var description: String? = nil 17 var publicKeys: [Pubkey] = [] 18 var interests: Set<DIP06.Interest> = [] 19 20 21 static func parse(from ev: NostrEvent) -> FollowPackEvent { 22 var followlist = FollowPackEvent(event: ev) 23 24 for tag in ev.tags { 25 guard tag.count >= 2 else { continue } 26 switch tag[0].string() { 27 case "title": followlist.title = tag[1].string() 28 case "d": followlist.uuid = tag[1].string() 29 case "image": followlist.image = URL(string: tag[1].string()) 30 case "description": followlist.description = tag[1].string() 31 case "p": 32 followlist.publicKeys.append(Pubkey(Data(hex: tag[1].string()))) 33 case "t": 34 if let interest = DIP06.Interest(rawValue: tag[1].string()) { 35 followlist.interests.insert(interest) 36 } 37 default: 38 break 39 } 40 } 41 42 return followlist 43 } 44 }