another.im-ios/AnotherIM/xmpp/modules/roster/RosterModule.swift
2024-12-17 09:20:04 +01:00

29 lines
760 B
Swift

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(from: 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
}
}
}