So I tagged the Web Artifact Creator bot in a new topic in a private category which the group has access so it can make an artifact only viewable to me and that particular group. However the artifact iframe window only shows that default " Oops! That page doesn’t exist or is private." that pops up when a user doesn’t have access to a particular page
So I made a data explorer query to check who could view that topic and the users in that group that should be able to see the artifact are indeed shown to be able to view it according to the database.
So perhaps this is a bug?
My SQL query
-- [params]
-- int :artifact_id = 22
WITH artifact_info AS (
SELECT
a.id,
a.user_id as creator_id,
a.post_id,
p.topic_id,
t.category_id,
t.archetype,
c.read_restricted,
t.title as topic_title
FROM ai_artifacts a
LEFT JOIN posts p ON a.post_id = p.id
LEFT JOIN topics t ON p.topic_id = t.id
LEFT JOIN categories c ON t.category_id = c.id
WHERE a.id = :artifact_id
),
users_with_access AS (
-- Creator always has access
SELECT
ai.creator_id as user_id,
'Creator' as access_reason
FROM artifact_info ai
UNION
-- Users with access to private messages
SELECT
tau.user_id,
'Private Message Access' as access_reason
FROM artifact_info ai
JOIN topic_allowed_users tau ON ai.topic_id = tau.topic_id
WHERE ai.archetype = 'private_message'
UNION
-- Group members with access to private messages
SELECT
gu.user_id,
'Private Message Group Access' as access_reason
FROM artifact_info ai
JOIN topic_allowed_groups tag ON ai.topic_id = tag.topic_id
JOIN group_users gu ON tag.group_id = gu.group_id
WHERE ai.archetype = 'private_message'
UNION
-- Users with access to restricted categories
SELECT
gu.user_id,
'Category Group Access' as access_reason
FROM artifact_info ai
JOIN category_groups cg ON ai.category_id = cg.category_id
JOIN group_users gu ON cg.group_id = gu.group_id
WHERE ai.read_restricted = true
AND ai.archetype != 'private_message'
AND cg.permission_type IN (1, 2) -- full access or create/reply/see
UNION
-- All users if topic is public (not restricted and not private message)
SELECT
u.id as user_id,
'Public Access' as access_reason
FROM artifact_info ai
CROSS JOIN users u
WHERE (ai.read_restricted = false OR ai.read_restricted IS NULL)
AND (ai.archetype != 'private_message' OR ai.archetype IS NULL)
AND u.active = true
)
SELECT
u.id as user_id,
u.username,
u.name,
u.trust_level,
uwa.access_reason,
ai.topic_title
FROM users_with_access uwa
JOIN users u ON uwa.user_id = u.id
CROSS JOIN artifact_info ai
WHERE u.active = true
ORDER BY u.username