Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/activity-contributor-legacy-strings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hypercerts-org/hypercerts-api': patch
---

Activity responses now tolerate legacy contributor URI strings without failing hydration. The original activity record is preserved, while those strings are omitted from the hydrated `contributors` projection.
2 changes: 1 addition & 1 deletion api/lexicons/org.hypercerts.claim.getActivity.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"record": { "type": "ref", "ref": "org.hypercerts.claim.activity" },
"contributors": {
"type": "array",
"description": "Hydrated contributor projection in the same order and with the same multiplicity as record.contributors; omitted only when the source field is absent.",
"description": "Hydrated projection of object entries in record.contributors, preserving their relative order and multiplicity; legacy string entries are skipped and the original record remains unchanged. Omitted only when the source field is absent; if it contains no object entries, this is an empty array.",
"items": { "type": "ref", "ref": "#activityContributorView" }
}
}
Expand Down
38 changes: 20 additions & 18 deletions api/lua/endpoints/getActivity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
38 changes: 20 additions & 18 deletions api/lua/endpoints/listActivities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
38 changes: 20 additions & 18 deletions api/lua/endpoints/listCollectionItems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
38 changes: 20 additions & 18 deletions api/lua/endpoints/listEntityFollowing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
38 changes: 20 additions & 18 deletions api/lua/endpoints/searchActivities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
36 changes: 19 additions & 17 deletions api/lua/shared/activityProjection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,28 @@ local function activity_projection_hydrate_views(views)
error("ActivityQueryFailed: activity contributors are not an array", 0)
end
local projections = {}
for contributor_index, source in ipairs(source_contributors) do
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[contributor_index] = projection
for _, source in ipairs(source_contributors) do
if type(source) ~= "string" then
local projection = {}
for key, value in pairs(source) do projection[key] = value end
projection.contributorInformation = ACTIVITY_PROJECTION_NULL
projection.actor = ACTIVITY_PROJECTION_NULL
projections[#projections + 1] = projection

local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
local identity = source.contributorIdentity
local resolution = { projection = projection }
if type(identity) == "table" and type(identity.uri) == "string" and type(identity.cid) == "string" then
local key = activity_projection_identity_key(identity.uri, identity.cid)
resolution.information_key = key
if not seen_references[key] then
seen_references[key] = true
references[#references + 1] = { uri = identity.uri, cid = identity.cid }
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
end
elseif type(identity) == "table" then
resolution.identifier = identity.identity
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
contributor_resolutions[#contributor_resolutions + 1] = resolution
end
projected_contributors[view_index] = projections
end
Expand Down
Loading
Loading