commit
0f40578ca9
|
@ -29,7 +29,23 @@ export default async function getPublicUser(
|
||||||
(usernames) => usernames.username
|
(usernames) => usernames.username
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user?.isPrivate) {
|
const isInAPublicCollection = await prisma.collection.findFirst({
|
||||||
|
where: {
|
||||||
|
["OR"]: [
|
||||||
|
{ ownerId: user.id },
|
||||||
|
{
|
||||||
|
members: {
|
||||||
|
some: {
|
||||||
|
userId: user.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isPublic: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (user?.isPrivate && !isInAPublicCollection) {
|
||||||
if (requestingId) {
|
if (requestingId) {
|
||||||
const requestingUser = await prisma.user.findUnique({
|
const requestingUser = await prisma.user.findUnique({
|
||||||
where: { id: requestingId },
|
where: { id: requestingId },
|
||||||
|
|
|
@ -25,7 +25,30 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (targetUser?.isPrivate) {
|
if (!targetUser) {
|
||||||
|
return res
|
||||||
|
.setHeader("Content-Type", "text/plain")
|
||||||
|
.status(400)
|
||||||
|
.send("File inaccessible.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const isInAPublicCollection = await prisma.collection.findFirst({
|
||||||
|
where: {
|
||||||
|
["OR"]: [
|
||||||
|
{ ownerId: targetUser.id },
|
||||||
|
{
|
||||||
|
members: {
|
||||||
|
some: {
|
||||||
|
userId: targetUser.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isPublic: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (targetUser?.isPrivate && !isInAPublicCollection) {
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
return res
|
return res
|
||||||
.setHeader("Content-Type", "text/plain")
|
.setHeader("Content-Type", "text/plain")
|
||||||
|
|
|
@ -185,8 +185,11 @@ export default function PublicCollections() {
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<p className="ml-2 mt-1 text-gray-500 dark:text-gray-300">
|
<p className="ml-2 mt-1 text-gray-500 dark:text-gray-300">
|
||||||
By {collectionOwner.name} and {collection.members.length}{" "}
|
By {collectionOwner.name}
|
||||||
others.
|
{collection.members.length > 0
|
||||||
|
? ` and ${collection.members.length} others`
|
||||||
|
: undefined}
|
||||||
|
.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -334,7 +334,7 @@ export default function Account() {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p className="text-gray-500 dark:text-gray-300 text-sm">
|
<p className="text-gray-500 dark:text-gray-300 text-sm">
|
||||||
This will limit who can find and add you to other Collections.
|
This will limit who can find and add you to new Collections.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{user.isPrivate && (
|
{user.isPrivate && (
|
||||||
|
|
Ŝarĝante…
Reference in New Issue