another.im-ios/AnotherIM/xmpp/modules/roster/RosterModule.swift

29 lines
759 B
Swift
Raw Normal View History

2024-12-16 12:51:12 +00:00
import Foundation
final class RosterModule: XmppModule {
let id = "Roseter module"
func reduce(oldState: ClientState, with _: Event) -> ClientState {
oldState
}
func process(state: ClientState, with event: Event) async -> Event? {
switch event {
case .streamReady:
return .requestRoster
case .requestRoster:
// TODO: check version!
let req = Stanza.iqGet(jid: state.jid.full, payload: XMLElement(name: "query", xmlns: "jabber:iq:roster", attributes: [:], content: nil, nodes: []))
if let req {
return .stanzaOutbound(req)
} else {
return nil
}
default:
return nil
}
}
}