Skip to content

Commit

Permalink
Merge develop branch into main for Sprint 4 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerbie-goober authored Aug 2, 2024
1 parent e90e749 commit fab0fd7
Show file tree
Hide file tree
Showing 44 changed files with 1,168 additions and 296 deletions.
6 changes: 3 additions & 3 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP_EMAIL=[email protected]
CLIENT_ID=1052354276038-14skrtgl53180hdbag91vk32buoc3bd1.apps.googleusercontent.com
CLIENT_SECRET=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
REFRESH_TOKEN=1//04gr_h2j1KQxkCgYIARAAGAQSNwF-L9Ir-FyAi8HZr3PTnU0Fn6WMq6UVpVCfiVXbBpQHIglLgBSdVgE-E-ybzMMEpzUKLQzhIx4
CLIENT_ID=1052354276038-dvs2amldtngierae907553p4i40lcg5t.apps.googleusercontent.com
CLIENT_SECRET=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
REFRESH_TOKEN=1//04p9TDi3BW4kZCgYIARAAGAQSNwF-L9IrLRfzg2YR_hUmH056NNsc7OZJYNngT4ySBxQoi_9yxK_w1Te2cVwxISney3fcRBRfmCU
ACCESS_TOKEN=ya29.a0AXooCgvaKx-2ILO6LmSRpyF3R_w0yiVcaQn28K_YChh-rNA4r7ooQUer2ISom0FA6NMk2LmL6oa6A2sl0K3Eek9X_X7vAotzNrQUpL0EvmF31KeDc-QHkMVueUN8i7HQ63-n0oo2p2ywaNm3YVZ87m-aqujF9nkHClqIaCgYKAVYSARISFQHGX2MiuPCr8QsOL6t4kYg5cxj-mQ0171
ACCESS_TOKEN_SECRET_FORJWT=5AFXgIWj8SAilS0T3ph0q2GEf7xzSYdXjCDMhrGLcvqrbqLq0rkedlc8s0tkLDJm
6 changes: 6 additions & 0 deletions backend/API/addComments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express');
const mongoose = require('mongoose');
const Comment = require('../schema/comments');
const isBad = require('../Utils/CommentFilter');

const addCommentHandler = async (req, res) => {
try {
Expand All @@ -12,6 +13,11 @@ const addCommentHandler = async (req, res) => {
return res.status(400).json({ error: 'Invalid resume ID format' });
}

// Check for profanity
if (isBad(comment)) {
return res.status(400).json({ error: 'Your comment contains inappropriate language.' });
}

console.log({ resumeId, user, comment, highlightedText, position }); // Log incoming data

const newComment = new Comment({
Expand Down
38 changes: 38 additions & 0 deletions backend/API/getProfilePic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const mongoose = require("mongoose");
const User = require("../schema/user");
const express = require('express');
const cors = require('cors');

// Middleware
const app = express();
app.use(cors());
app.use(express.json());

require('dotenv').config();

// API call to create new object
const getProfilePic = async (req, res) => {
try {
// Using the passed from front-end object
const passedUser = req.body;

const user = await User.findOne({
anon_username: passedUser.username
});

if (!user) {
return res.status(401).json({errorMsg : "Unable to find user"});
}

console.log(user.anon_username);
console.log(user.avatar);

// Send tokens to the frontend
res.status(200).json({profilePic: user.avatar});

} catch (error) {
res.status(500).send('Error getting profile pic: ' + error.message);
}
};

module.exports = getProfilePic;
24 changes: 24 additions & 0 deletions backend/API/getUserResumesAndComments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const Resume = require('../schema/resume');
const Comment = require('../schema/comments');

// API call to fetch resumes with comments for a specific user
const getUserResumesAndComments = async (req, res) => {
try {
const userId = req.params.userId;
const resumes = await Resume.find({ uploader_id: userId }).populate('uploader_id');

const resumesWithComments = await Promise.all(resumes.map(async (resume) => {
const comments = await Comment.find({ resumeId: resume._id });
return {
...resume.toObject(),
comments
};
}));

res.json(resumesWithComments);
} catch (error) {
res.status(500).json({ error: 'Error fetching resumes with comments' });
}
};

module.exports = getUserResumesAndComments;
4 changes: 2 additions & 2 deletions backend/API/getUserbyId.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const getUser = async (req, res) => {
const userId = req.params.userId;

// Get list of resumes that user has already swiped on
const targetUser = await User.find({ _id: userId });

const targetUser = await User.findById(userId);
console.log('Returning User:', targetUser); // Log the resume data
res.json(targetUser);
} catch (error) {
console.error('Error fetching user:', error);
Expand Down
2 changes: 1 addition & 1 deletion backend/API/newUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const newUser = async (req, res) => {
work_experience_level: passedUser.work_experience_level,
education: passedUser.education,
location: passedUser.location,
avatar: "",
avatar: "bearTwemoji.png",
salt: generatedSalt,
verified: false,
verificationToken: token,
Expand Down
5 changes: 5 additions & 0 deletions backend/API/postTrendingComment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const TrendingComment = require('../schema/trendingComment');
const isBad = require('../Utils/CommentFilter');

const postTrendingComment = async (req, res) => {
const { resumeId, text, username, parentId = null } = req.body;

if (isBad(text)) {
return res.status(400).json({ error: 'Your comment contains inappropriate language.' });
}
const newComment = new TrendingComment({ resumeId, text, username, parentId });
try {
await newComment.save();
Expand Down
28 changes: 28 additions & 0 deletions backend/API/setProfilePic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const mongoose = require("mongoose");
const User = require('../schema/user');
const express = require('express');
const cors = require('cors');

// Middleware
const app = express();
app.use(cors());
app.use(express.json());

const setProfilePic = async (req, res) => {
try {
const passedInfo = req.body;

// Mark all messages from another person as read
await User.updateOne(
{ anon_username: passedInfo.username },
{ $set: { avatar: passedInfo.filename } }
);

return res.status(200).json({ message: "updated"});

} catch (error) {
return res.status(500).json({ message: error.message, isValid: false });
}
};

module.exports = setProfilePic;
7 changes: 7 additions & 0 deletions backend/Utils/CommentFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const Filter = require('bad-words');
const filter = new Filter();
const customWords = ['stupid', 'idiot', 'dumb', 'crazy','hate','bad','horrible','terrible']; // Add more as needed
filter.addWords(...customWords)
const isBad = (text) => filter.isProfane(text);

module.exports = isBad;
17 changes: 17 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "ISC",
"description": "",
"dependencies": {
"bad-words": "^3.0.4",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"crypto": "^1.0.1",
Expand Down
9 changes: 9 additions & 0 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const getUserResumes = require('./API/getUserResumes');
const displayResumes = require('./API/displayResumes');
const deleteResumes = require('./API/deleteResumes');
const updateResumePublicStatus = require('./API/updateResume');
const getUserResumesAndComments = require('./API/getUserResumesAndComments');
const getSwipingResumes = require('./API/getSwipingResumes');
const addSwipe = require('./API/addSwipe');
const checkMatch = require('./API/checkMatch');
Expand All @@ -38,6 +39,10 @@ const getUploaderName = require('./API/getUserName');
const updateDmStatus = require('./API/updateDmStatus');
const getDmStatus = require('./API/getDmStatus');

// Profile pic API's
const setProfilePic = require('./API/setProfilePic');
const getProfilePic = require('./API/getProfilePic');

require('dotenv').config();

const MONGO_DB = "mongodb+srv://Cluster20901:[email protected]/linkup?retryWrites=true&w=majority&appName=Cluster20901";
Expand Down Expand Up @@ -124,6 +129,7 @@ conn.once('open', () => {
// RESUMES
app.post('/upload', upload.single('file'), uploadResumes);
app.get('/resumes/:userId', getUserResumes);
app.get('/resumes/:userId/reviewed', getUserResumesAndComments); // Update route to use the new handler
app.get('/bucket/files/:filename', displayResumes(gfsBucket));
app.post('/delete-resumes', deleteResumes(gfsBucket));
app.post('/api/update-resume', updateResumePublicStatus);
Expand Down Expand Up @@ -187,6 +193,9 @@ app.get('/api/get-uploader-name/:userId', getUploaderName);
// app.use('/api/resume', addComments);
// app.use('/api/resume', getComments);

// Profile Pics
app.post('/set-profile-pic', setProfilePic);
app.post('/get-profile-pic', getProfilePic);

// Listening on Port 3001
const PORT = 3001;
Expand Down
4 changes: 4 additions & 0 deletions doc/sprint3/SprintReview_03.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,26 @@ Users are able to highlight text and leave comments on resumes that they swipe r
Leave comments on trending resumes (LC-31)
As a registered user, I can write and publish public comments on trending documents so that I can leave feedback on documents that I may not have seen.
This allows registered users to engage with the community by writing and publishing public comments on trending documents. This feature encourages interaction and feedback on popular content, enhancing the community experience and fostering discussions on relevant topics.

![TrendResume](../../frontend/src/images/Sprint3trend.png)


Deleting Conversations (LC-30)
Users can delete all their messages (deleting conversation), or delete single messages
When a user deletes a message, the other user will be shown that the message has been deleted (similar to WhatsApp). This ensures fair control for both users over their conversation

![DeleteMsg](../../frontend/src/images/delete.png)



Block user in dms (LC-36)
Users have the option to block other users to prevent further communication. When a user blocks another user, the blocked user will not be notified that they have been blocked. This feature ensures that users have full control over who can interact with them, maintaining a fair and respectful environment for all participants in the conversation.

![UserBlock](../../frontend/src/images/userblock.png)

Edit Swiping Preferences (LC-32)
Users have the option to edit their swiping preferences whenever. Navigating to the “Your Profile” page, they can click the “Edit Preferences” button to modify their preferences by clicking on an option in the dropdown for each option.

![TrendResume](../../frontend/src/images/Sprint03_profilepage_with_edit_preferences.png)

#### Goals and/or tasks that were planned but not met/completed:
Expand Down
9 changes: 9 additions & 0 deletions doc/sprint3/iteration_plan03.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,38 @@ For Sprint 3
As a registered user, I want to be able to edit my preferences so that I can modify my swiping experience whenever.
**Purpose:**
It is focused on allowing users to have control over their preferences within the application. By enabling users to edit their preferences, they can tailor their swiping experience to better match their interests and needs, ensuring a more personalized and satisfactory user experience.

![TrendResume](../../frontend/src/images/Sprint03_profilepage_with_edit_preferences.png)

#### LC-30

As a registered user, I want to delete conversations with users that I have matched with so that I can manage my chat history.
**Purpose:**
This ticket addresses the need for users to have the ability to manage their chat history by deleting conversations. This feature helps users maintain their privacy, declutter their chat interface, and remove any unwanted or outdated conversations.

![DeleteMsg](../../frontend/src/images/delete.png)

#### LC-36

As a registered user, I can block users that I have matched with so that I can prevent users from talking to me.
**Purpose:**
The focus of this ticket is to provide users with the capability to block other users they have matched with. This is crucial for ensuring user safety and comfort by allowing them to prevent unwanted communication and interactions from specific users.

![UserBlock](../../frontend/src/images/userblock.png)

#### LC-28

As a user, I want to be able to leave comments on the document of the user that I have swiped right on.
**Purpose:**
This enables users to leave comments on the documents of users they have shown interest in by swiping right. This feature facilitates further interaction and engagement between users, allowing them to express their thoughts or feedback directly on the documents.

![TrendResume](../../frontend/src/images/addingcomments.png)

#### LC-31
As a registered user, I can write and publish public comments on trending documents so that I can leave feedback on documents that I may not have seen.
**Purpose:**
This allows registered users to engage with the community by writing and publishing public comments on trending documents. This feature encourages interaction and feedback on popular content, enhancing the community experience and fostering discussions on relevant topics.

![TrendResume](../../frontend/src/images/Sprint3trend.png)


Expand Down
6 changes: 6 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.19.2",
"extract-colors": "^4.0.6",
"lodash": "^4.17.21",
"mongodb": "^5.9.1",
"mongoose": "^6.13.0",
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
}

.app-logo-container {
top:0;
width: 100%;
padding: 20px;
justify-content: center;
display: flex;
}
Expand Down Expand Up @@ -126,22 +125,19 @@
.container {
font-family: 'Roboto';
background-color: #bfe7f6;
min-height: 100vh;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 20px;
width: 100%;
position: relative;
margin-bottom: 100%;
}

/* Apply the background color to the html and body */
html, body {
height: 100%;
margin: 0;
padding: 0;
padding-bottom: 30px;
background-color: #bfe7f6; /* Same as your container background color */
font-family: 'Roboto', sans-serif;
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import MatchPage from "./pages/MatchPage";
import ResumeComment from './pages/ResumeComment';
import ViewResumeComments from './pages/ViewResumeComments';
import TrendingResumes from './pages/TrendingResumes.js';

import ReviewedResumes from './pages/ReviewedResumes.js';

// React Auth Kit
import createStore from 'react-auth-kit/createStore';
Expand Down Expand Up @@ -58,6 +58,7 @@ function App() {
<Route path="/resume-comment/:resumeId" element={<ResumeComment/>} />
<Route path="/view-resume-comments/:resumeId/:commenter" element={<ViewResumeComments />} />
<Route path="/edit-preferences" element={<PreferencesPage/>} />
<Route path="/reviewed-resumes" element={<ReviewedResumes/>} />
</Routes>
</div>
</BrowserRouter>
Expand Down
Loading

0 comments on commit fab0fd7

Please sign in to comment.