aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 17:01:10 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 17:01:10 +0200
commit7bc609a85b43ed86eccb9cd40d9db31f15aaba1d (patch)
tree80b31e39e029bb89793d95fab76bf8310031d76d /shard/lib/app
parent76749e8f64ce3caf7e0e5c17dfee373dcf4dfe6e (diff)
downloadshard-7bc609a85b43ed86eccb9cd40d9db31f15aaba1d.tar.gz
shard-7bc609a85b43ed86eccb9cd40d9db31f15aaba1d.zip
More notifications going around
Diffstat (limited to 'shard/lib/app')
-rw-r--r--shard/lib/app/chat.ex6
-rw-r--r--shard/lib/app/identity.ex6
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
# ================