Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tag forwarding #2

Merged
merged 3 commits into from
Jun 22, 2024
Merged
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
38 changes: 36 additions & 2 deletions src/common/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,45 @@ function ant.init()
return
end

ao.send({ Target = msg.From, Data = nameRes })
local recordNotice = {
Target = msg.From,
Action = 'Record-Notice',
Name = msg.Tags["Sub-Domain"],
Data = nameRes
}

-- Add forwarded tags to the credit and debit notice messages
for tagName, tagValue in pairs(msg) do
-- Tags beginning with "X-" are forwarded
if string.sub(tagName, 1, 2) == "X-" then
recordNotice[tagName] = tagValue
end
end

-- Send Record-Notice
ao.send(recordNotice)
end)

Handlers.add(camel(ActionMap.GetRecords), utils.hasMatchingTag("Action", ActionMap.GetRecords), function(msg)
ao.send({ Target = msg.From, Data = records.getRecords() })
local records = records.getRecords()

-- Credit-Notice message template, that is sent to the Recipient of the transfer
local recordsNotice = {
Target = msg.From,
Action = 'Records-Notice',
Data = json.encode(records)
}

-- Add forwarded tags to the records notice messages
for tagName, tagValue in pairs(msg) do
-- Tags beginning with "X-" are forwarded
if string.sub(tagName, 1, 2) == "X-" then
recordsNotice[tagName] = tagValue
end
end

-- Send Records-Notice
ao.send(recordsNotice)
end)

Handlers.add(camel(ActionMap.SetName), utils.hasMatchingTag("Action", ActionMap.SetName), function(msg)
Expand Down