Merge branch 'use-daisyui-for-better-dx' of https://github.com/linkwarden/linkwarden into use-daisyui-for-better-dx

This commit is contained in:
daniel31x13 2023-11-24 13:59:32 -05:00
commit a33d68c03a
4 changed files with 52 additions and 6 deletions

View File

@ -29,7 +29,23 @@ export default async function getPublicUser(
(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) {
const requestingUser = await prisma.user.findUnique({
where: { id: requestingId },

View File

@ -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) {
return res
.setHeader("Content-Type", "text/plain")
@ -53,7 +76,11 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
.send("File inaccessible.");
}
if (user.username && !whitelistedUsernames?.includes(user.username)) {
if (
user.username &&
!whitelistedUsernames?.includes(user.username) &&
targetUser.id !== user.id
) {
return res
.setHeader("Content-Type", "text/plain")
.status(400)

View File

@ -185,8 +185,11 @@ export default function PublicCollections() {
) : null}
<p className="ml-2 mt-1 text-gray-500 dark:text-gray-300">
By {collectionOwner.name} and {collection.members.length}{" "}
others.
By {collectionOwner.name}
{collection.members.length > 0
? ` and ${collection.members.length} others`
: undefined}
.
</p>
</div>
</div>

View File

@ -328,7 +328,7 @@ export default function Account() {
/>
<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>
{user.isPrivate && (