Skip to content

Commit

Permalink
change: show explication post in Auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
Nem-Tudo authored Sep 16, 2024
1 parent cc06918 commit 24af30a
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,14 @@ app.get("/xrpc/app.bsky.feed.getFeedSkeleton", async (req, res) => {
"at://did:plc:xy3lxva6bqrph3avrvhzck7q/app.bsky.feed.generator/bookmarks"
) {
if (!req.headers.authorization)
return res.status(401).json({ message: "Unauthorized" });
return res.json({
cursor: `${Date.now()}_${randomString(5, false)}`,
feed: [
{
post: cache.settings.config.defaultBookmarksPost,
},
], //No bookmarks post
});

// const authorization = verifyJWT(req.headers.authorization.replace('Bearer ', '').trim(), process.env.FEED_KEY);

Expand All @@ -1019,12 +1026,26 @@ app.get("/xrpc/app.bsky.feed.getFeedSkeleton", async (req, res) => {
//---------------------

if (authorization.error)
return res.status(401).json({ message: "Unauthorized" });
return res.json({
cursor: `${Date.now()}_${randomString(5, false)}`,
feed: [
{
post: cache.settings.config.defaultBookmarksPost,
},
], //No bookmarks post
});

const user = await UserSchema.findOne({
d: String(authorization.data.iss),
});
if (!user) return res.status(404).json({ message: "User not found" });
if (!user) return res.json({
cursor: `${Date.now()}_${randomString(5, false)}`,
feed: [
{
post: cache.settings.config.defaultBookmarksPost,
},
], //No bookmarks post
});

const bookmarks = await BookmarkSchema.find({
userdid: user.d,
Expand Down

0 comments on commit 24af30a

Please sign in to comment.