Skip to content

Commit

Permalink
fix: replace bearer in token
Browse files Browse the repository at this point in the history
  • Loading branch information
Nem-Tudo committed Sep 14, 2024
1 parent 488f179 commit 523840c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,28 +849,32 @@ app.put("/api/admin/blacklist", async (req, res) => {

// xrpc
app.get("/xrpc/app.bsky.feed.getFeedSkeleton", async (req, res) => {
console.log(req, req.query, req.headers.authorization)

if(!req.headers.authorization) return res.status(401).json({message: "Unauthorized"})
if (req.query.feed == "at://did:plc:xy3lxva6bqrph3avrvhzck7q/app.bsky.feed.generator/bookmarks") {
if (!req.headers.authorization) return res.status(401).json({ message: "Unauthorized" })

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

console.log(authorization)
console.log(authorization)

if(authorization.error) return res.status(401).json({message: "Unauthorized"})
if (authorization.error) return res.status(401).json({ message: "Unauthorized" })

const user = await UserSchema.findOne({ d: authorization.data.iss });
if (!user) return res.status(404).json({ message: "User not found" });
const user = await UserSchema.findOne({ d: authorization.data.iss });
if (!user) return res.status(404).json({ message: "User not found" });

const bookmarks = await BookmarkSchema.find({ userdid: user.d, enabled: true });
const bookmarks = await BookmarkSchema.find({ userdid: user.d, enabled: true });


return res.json(
{
cursor: `${Date.now()}_${randomString(5, false)}`,
feed: bookmarks.map(uri => { return { post: uri } })
}
)
return res.json(
{
cursor: `${Date.now()}_${randomString(5, false)}`,
feed: bookmarks.map(uri => { return { post: uri } })
}
)
}

return res.status(404).json({ message: "Feed not found" });

})

app.get("/xrpc/app.bsky.feed.describeFeedGenerator", (req, res) => {
Expand Down

0 comments on commit 523840c

Please sign in to comment.