-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attach session details inside account
- Loading branch information
Showing
1 changed file
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ class BuildMessageOptions | |
def call(params) | ||
headers = yield build_headers(params) | ||
payload = yield build_payload(params) | ||
headers = yield append_session_details(headers) | ||
headers = yield append_account_details(headers) | ||
|
||
Success(headers: headers, payload: payload) | ||
end | ||
|
@@ -36,17 +36,20 @@ def build_payload(params) | |
Success(payload) | ||
end | ||
|
||
def append_session_details(headers) | ||
def append_account_details(headers) | ||
output = FetchSession.new.call | ||
account = {} | ||
|
||
if output.success? | ||
session, current_user = output.value! | ||
headers[:session] = session&.symbolize_keys | ||
account[:session] = session&.symbolize_keys | ||
else | ||
# Create system account user <[email protected]> when session is not available | ||
current_user = system_account if defined?(system_account) | ||
end | ||
headers[:account_id] = current_user&.id&.to_s | ||
|
||
account[:id] = current_user&.id&.to_s | ||
headers[:account] = account | ||
|
||
Success(headers) | ||
end | ||
|