Skip to content

Commit

Permalink
fix(cu): use From-Process tag to set From and Forwarded-By #267
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Jan 2, 2024
1 parent 67a8f00 commit de0ae07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 3 additions & 13 deletions servers/cu/src/domain/client/ao-su.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ export const loadMessagesWith = ({ fetch, logger: _logger, pageSize }) => {
}

function mapFrom (node) {
const tag = findRawTag('Forwarded-For', node.message.tags)
const tag = findRawTag('From-Process', node.message.tags)
/**
* Not forwarded, so the signer is the who the message is from
*/
if (!tag || !tag.value) return node.owner.address
/**
* Forwarded, so the owner is who the message was forwarded on behalf of
* (the Forwarded-For) value
* (the From-Process) value
*/
return tag.value
}

function mapForwardedBy (node) {
const tag = findRawTag('Forwarded-For', node.message.tags)
const tag = findRawTag('From-Process', node.message.tags)
/**
* Not forwarded by a MU, so simply not set
*/
Expand All @@ -94,15 +94,6 @@ export const loadMessagesWith = ({ fetch, logger: _logger, pageSize }) => {
return node.owner.address
}

/**
* Simply derived from the tag added by the MU, when cranking a message
*/
function mapForwardedFor (node) {
const tag = findRawTag('Forwarded-For', node.message.tags)
if (!tag) return undefined
return tag.value
}

function mapAoMessage ({ processId, processOwner, processTags }) {
return async function * (edges) {
for await (const edge of edges) {
Expand All @@ -128,7 +119,6 @@ export const loadMessagesWith = ({ fetch, logger: _logger, pageSize }) => {
Anchor: path(['message', 'anchor']),
From: mapFrom,
'Forwarded-By': mapForwardedBy,
'Forwarded-For': mapForwardedFor,
Tags: pathOr([], ['message', 'tags']),
Epoch: path(['epoch']),
Nonce: path(['nonce']),
Expand Down
1 change: 0 additions & 1 deletion servers/cu/src/domain/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const messageSchema = z.object({
Anchor: z.string().optional(),
From: z.string().min(1),
'Forwarded-By': z.string().optional(),
'Forwarded-For': z.string().optional(),
Tags: z.array(rawTagSchema),
/**
* cron messages do not have a nonce or epoch
Expand Down

0 comments on commit de0ae07

Please sign in to comment.