diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-12 17:01:10 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-12 17:01:10 +0200 |
commit | 7bc609a85b43ed86eccb9cd40d9db31f15aaba1d (patch) | |
tree | 80b31e39e029bb89793d95fab76bf8310031d76d /shard/lib/app | |
parent | 76749e8f64ce3caf7e0e5c17dfee373dcf4dfe6e (diff) | |
download | shard-7bc609a85b43ed86eccb9cd40d9db31f15aaba1d.tar.gz shard-7bc609a85b43ed86eccb9cd40d9db31f15aaba1d.zip |
More notifications going around
Diffstat (limited to 'shard/lib/app')
-rw-r--r-- | shard/lib/app/chat.ex | 6 | ||||
-rw-r--r-- | shard/lib/app/identity.ex | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/shard/lib/app/chat.ex b/shard/lib/app/chat.ex index 8d55cda..8c55869 100644 --- a/shard/lib/app/chat.ex +++ b/shard/lib/app/chat.ex @@ -228,6 +228,7 @@ defmodule SApp.Chat do GenServer.cast(state.page_store, {:set_roots, [mst2.root]}) save_state(state) msg_callback(state, msgitem) + SNet.Group.broadcast(state.netgroup, {state.id, nil, msg}, exclude_pid: [conn_pid]) state else Logger.warn("Invalid new root after inserting same message item!") @@ -262,6 +263,8 @@ defmodule SApp.Chat do end defp init_merge(state, new_root, source_peer_pid) do + old_root = state.mst.root + if new_root == nil do state else @@ -291,6 +294,9 @@ defmodule SApp.Chat do GenServer.cast(state.page_store, {:set_roots, [mst.root]}) state = %{state | mst: mst} save_state(state) + if state.mst.root != old_root do + SNet.Group.broadcast(state.netgroup, {state.id, nil, {:root, state.mst.root, false}}, exclude_pid: [source_peer_pid]) + end state else Logger.warn("Incorrect signatures somewhere while merging, dropping merged data") diff --git a/shard/lib/app/identity.ex b/shard/lib/app/identity.ex index 02e8eb9..95ffb92 100644 --- a/shard/lib/app/identity.ex +++ b/shard/lib/app/identity.ex @@ -112,9 +112,9 @@ defmodule SApp.Identity do {:noreply, state} end - defp bcast_state(state, _exclude \\ []) do - # TODO: effectively apply exclude list - SNet.Group.broadcast(state.netgroup, {state.id, nil, {:update, SData.SignRev.signed(state.state), false}}) + defp bcast_state(state, exclude \\ []) do + msg = {state.id, nil, {:update, SData.SignRev.signed(state.state), false}} + SNet.Group.broadcast(state.netgroup, msg, exclude_pid: exclude) end # ================ |