Add prencence option in sync
parent
edb59b7a8e
commit
21d3fb2814
|
@ -1,6 +1,8 @@
|
|||
function sync(u::MatrixUser;
|
||||
timeout = 0, since::Union{String,Nothing} = nothing, full = false)
|
||||
timeout = 0, since::Union{String,Nothing} = nothing, full = false,
|
||||
presence = "offline")
|
||||
req = Dict("timeout" => string(timeout),
|
||||
"set_presence" => presence,
|
||||
"full" => string(full))
|
||||
since === nothing ? nothing : (req["since"] = string(since))
|
||||
get(u, "sync"; extraquery = req)
|
||||
|
@ -9,9 +11,9 @@ end
|
|||
function sync!(s::MatrixSync)
|
||||
# initial sync
|
||||
res = s.last in [nothing, ""] ?
|
||||
sync(s.user, timeout = s.timeout, full = true) :
|
||||
sync(s.user, timeout = s.timeout, full = true, presence = s.presence) :
|
||||
# updates
|
||||
sync(s.user, since = s.last, timeout = s.timeout, full = false)
|
||||
sync(s.user, since = s.last, timeout = s.timeout, full = false, presence = s.presence)
|
||||
res = JSON.parse(String(res.body))
|
||||
s.last = res["next_batch"]
|
||||
s.sync = res
|
||||
|
|
|
@ -35,6 +35,7 @@ mutable struct MatrixSync
|
|||
user::MatrixUser
|
||||
last::Union{Nothing,String}
|
||||
timeout::Int
|
||||
presence::String
|
||||
sync
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue