mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat(threads): gateway, messages and push thread support (#3250)
This commit is contained in:
1 parent
4e730832c7
commit
5f4295e399
108 files changed
+15857
-176
No files matched your search
@@ -126,3 +126,59 @@ session_loop() ->
|
||||
after infinity ->
|
||||
ok
|
||||
end.
|
||||
|
||||
export_handoff_state_replaces_the_thread_store_with_rows_test() ->
|
||||
Tab = guild_thread_store:new(),
|
||||
ok = guild_thread_store:put_thread(Tab, #{<<"id">> => 10, <<"parent_id">> => 1}),
|
||||
try
|
||||
State = #{
|
||||
id => 12345,
|
||||
data => #{thread_store => Tab, thread_gate => #{active => true, version => 1}},
|
||||
sessions => #{}
|
||||
},
|
||||
Data = maps:get(data, guild_handoff:export_handoff_state(State)),
|
||||
?assertNot(maps:is_key(thread_store, Data)),
|
||||
?assertEqual(#{active => true, version => 1}, maps:get(thread_gate, Data)),
|
||||
?assertEqual(guild_thread_store:export(Tab), maps:get(thread_rows, Data)),
|
||||
?assert(is_integer(maps:get(thread_rows_at, Data)))
|
||||
after
|
||||
guild_thread_store:destroy(Tab)
|
||||
end.
|
||||
|
||||
init_from_export_queues_a_flip_when_the_gate_disagrees_with_config_test() ->
|
||||
Tab = guild_thread_store:new(),
|
||||
ok = guild_thread_store:put_thread(Tab, #{<<"id">> => 10, <<"parent_id">> => 1}),
|
||||
Key = channel_threads_config,
|
||||
Previous = persistent_term:get(Key, undefined),
|
||||
try
|
||||
Exported = guild_handoff:export_handoff_state(#{
|
||||
id => 12345,
|
||||
data => #{thread_store => Tab, thread_gate => #{active => true, version => 4}},
|
||||
sessions => #{}
|
||||
}),
|
||||
persistent_term:put(Key, (channel_threads_config:default_config())#{
|
||||
enabled => true, config_version => 5
|
||||
}),
|
||||
_ = guild_init:init_base_state(Exported),
|
||||
?assertEqual([5], drain_flips([])),
|
||||
persistent_term:put(Key, (channel_threads_config:default_config())#{
|
||||
enabled => true, config_version => 5, enabled_guilds => #{<<"12345">> => true}
|
||||
}),
|
||||
_ = guild_init:init_base_state(Exported),
|
||||
?assertEqual([], drain_flips([])),
|
||||
persistent_term:erase(Key),
|
||||
_ = guild_init:init_base_state(Exported),
|
||||
?assertEqual([], drain_flips([]))
|
||||
after
|
||||
guild_thread_store:destroy(Tab),
|
||||
case Previous of
|
||||
undefined -> persistent_term:erase(Key);
|
||||
_ -> persistent_term:put(Key, Previous)
|
||||
end
|
||||
end.
|
||||
|
||||
drain_flips(Acc) ->
|
||||
receive
|
||||
{thread_gate_flip, Version} -> drain_flips([Version | Acc])
|
||||
after 0 -> lists:reverse(Acc)
|
||||
end.
|
||||
Reference in new issue
Block a user