Add profile image, topics for other user page

This commit is contained in:
Leon Liang
2019-11-19 15:56:39 -05:00
parent c8aa1fd050
commit 42c53fdbc4
3 changed files with 161 additions and 2 deletions

View File

@@ -58,3 +58,16 @@ exports.deleteTopic = (req, res) => {
return res.status(500).json({ error: "Failed to delete topic." });
});
};
exports.getUserTopics = (req, res) => {
let data = [];
db.doc(`/users/${req.body.handle}`)
.get()
.then(doc => {
data = doc.data().followedTopics;
return res.status(200).json({ data });
})
.catch(err => {
return res.status(500).json({ err });
});
};

View File

@@ -37,7 +37,7 @@ app.post("/login", login);
//Deletes user account
app.delete("/delete", fbAuth, deleteUser);
app.get("/getUser", fbAuth, getUserDetails);
app.post("/getUserDetails", fbAuth, getUserDetails);
// Returns all profile data of the currently logged in user
app.get("/getProfileInfo", fbAuth, getProfileInfo);
@@ -82,7 +82,12 @@ app.post("/putPost", fbAuth, putPost);
/*------------------------------------------------------------------*
* handlers/topic.js *
*------------------------------------------------------------------*/
const { putTopic, getAllTopics, deleteTopic } = require("./handlers/topic");
const {
putTopic,
getAllTopics,
deleteTopic,
getUserTopics
} = require("./handlers/topic");
// add topic to database
app.post("/putTopic", fbAuth, putTopic);
@@ -93,4 +98,7 @@ app.get("/getAllTopics", fbAuth, getAllTopics);
// delete a specific topic
app.delete("/deleteTopic/:topicId", fbAuth, deleteTopic);
// get topic for this user
app.post("/getUserTopics", fbAuth, getUserTopics);
exports.api = functions.https.onRequest(app);