wip
This commit is contained in:
parent
0dff34318b
commit
d95c9c1671
|
@ -81,6 +81,7 @@ identifier_name:
|
|||
- db
|
||||
- _db
|
||||
- iq
|
||||
- xa
|
||||
|
||||
# Disable rules from the default enabled set.
|
||||
disabled_rules:
|
||||
|
|
|
@ -43,6 +43,7 @@ enum Event {
|
|||
case streamReady
|
||||
|
||||
case requestRoster
|
||||
case rosterRequestDone
|
||||
case addRosterItem(jidStr: String, args: [String: String])
|
||||
case updateRosterItem(jidStr: String, args: [String: String])
|
||||
case deleteRosterItem(jidStr: String)
|
||||
|
|
28
AnotherXMPP/models/Presence.swift
Normal file
28
AnotherXMPP/models/Presence.swift
Normal file
|
@ -0,0 +1,28 @@
|
|||
import Foundation
|
||||
|
||||
enum PresenceType {
|
||||
case chat
|
||||
case online
|
||||
case away
|
||||
case xa
|
||||
case dnd
|
||||
|
||||
var weight: Int {
|
||||
switch self {
|
||||
case .chat:
|
||||
return 5
|
||||
|
||||
case .online:
|
||||
return 4
|
||||
|
||||
case .away:
|
||||
return 3
|
||||
|
||||
case .xa:
|
||||
return 2
|
||||
|
||||
case .dnd:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,16 @@ final class PresenceModule: XmppModule {
|
|||
oldState
|
||||
}
|
||||
|
||||
func process(state _: ClientState, with _: Event) async -> Event? {
|
||||
nil
|
||||
func process(state _: ClientState, with event: Event) async -> Event? {
|
||||
switch event {
|
||||
case .rosterRequestDone:
|
||||
return nil
|
||||
|
||||
case .stanzaInbound(let stanza):
|
||||
return nil
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,10 @@ final class RosterModule: XmppModule {
|
|||
return nil
|
||||
}
|
||||
|
||||
// when roster requested, also raise .done event
|
||||
case .rosterRequestDone:
|
||||
return .rosterUpdated
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
@ -220,7 +224,7 @@ private extension RosterModule {
|
|||
// save roster
|
||||
guard let data = try? JSONEncoder().encode(existItems.map { $0.wrapped }) else { return nil }
|
||||
await storage?.setRoster(jid: state.jid, roster: data)
|
||||
return .rosterUpdated
|
||||
return .rosterRequestDone
|
||||
|
||||
// for result of one of our request
|
||||
case .iq(.set):
|
||||
|
|
Loading…
Reference in a new issue