Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/delta/delta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ defmodule Delta do
|> Kernel.++(Plug.Conn.get_req_header(conn, "mu-call-id"))
|> Poison.encode!()

mu_call_scope_id = Plug.Conn.get_req_header(conn, "mu-call-scope-id")

mu_session_id =
Plug.Conn.get_req_header(conn, "mu-session-id")


delta
|> Delta.Message.construct(authorization_groups, origin)
|> Delta.Message.construct(authorization_groups, origin, mu_call_scope_id)
|> Logging.EnvLog.inspect(:log_delta_messages, label: "Constructed body for clients")
|> Delta.Messenger.inform_clients(mu_call_id_trail: mu_call_id_trail, mu_session_id: mu_session_id)

|> Delta.Messenger.inform_clients(mu_call_id_trail: mu_call_id_trail, mu_session_id: mu_session_id, mu_call_scope_id: mu_call_scope_id)
delta
end
end
9 changes: 7 additions & 2 deletions lib/delta/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ defmodule Delta.Message do
Constructs a new message which can be sent to the clients based on a
quad delta.
"""
@spec construct(Delta.delta(), AccessGroupSupport.decoded_json_access_groups(), String.t()) ::
@spec construct(Delta.delta(), AccessGroupSupport.decoded_json_access_groups(), String.t(), String.t()) ::
Delta.Message.t()
def construct(delta, access_groups, origin) do
def construct(delta, access_groups, origin, call_scope) do
# TODO we should include the current access rigths and an
# identifier for the originating service. This would help
# services ignore content which came from their end and would
Expand All @@ -33,6 +33,7 @@ defmodule Delta.Message do
|> convert_delta_item
|> add_allowed_groups(access_groups)
|> add_origin(origin)
|> add_call_scope(call_scope)
end)
}

Expand Down Expand Up @@ -62,6 +63,10 @@ defmodule Delta.Message do
Map.put(map, "origin", origin)
end

defp add_call_scope(map, call_scope) do
Map.put(map, "call-scope", call_scope)
end

defp convert_quad(%Quad{graph: graph, subject: subject, predicate: predicate, object: object}) do
[g, s, p, o] =
Enum.map(
Expand Down
1 change: 1 addition & 0 deletions lib/delta/messenger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defmodule Delta.Messenger do
# backoff if the sending of the message failed.
headers = [
{"Content-Type", "application/json"},
{"mu-call-scope-id", options[:mu_call_scope_id]},
{"mu-call-id", Integer.to_string(Enum.random(0..1_000_000_000_000))},
{"mu-call-id-trail", options[:mu_call_id_trail]},
{"mu-session-id", options[:mu_session_id]}
Expand Down