Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1696355
Update README.md
l-burrell Oct 5, 2021
5047500
Update HelloWorldRoute.ts
l-burrell Oct 5, 2021
1fcfdde
First commit
Jeremy524 Oct 5, 2021
f0eefb7
First commit + quick changes
Jeremy524 Oct 5, 2021
d7ec29f
Merge branch 'main' into Jeremiah_Anim/first-commit
DynasticINF Oct 5, 2021
8f1a842
Merge pull request #1 from DynasticINF/Jeremiah_Anim/first-commit
DynasticINF Oct 5, 2021
7b6558f
First Commit
Oct 6, 2021
4a01b1f
First Commit
ekowt Oct 6, 2021
93d6b42
First Commit Part2
ekowt Oct 6, 2021
040752d
Merge pull request #2 from DynasticINF/Ekow_Thompson/first-commit
ekowt Oct 6, 2021
8787952
Delete .env.devolopment
DynasticINF Oct 6, 2021
9a7d570
First Commit
tgthomp27 Oct 9, 2021
2765aab
Merge pull request #3 from DynasticINF/Tarah_Thompson/first-commit
tgthomp27 Oct 9, 2021
65b7935
Added my name and Twilio info
egarcia-flores Oct 9, 2021
043b749
Merge pull request #4 from DynasticINF/e_garcia-flores/first-commit2
egarcia-flores Oct 9, 2021
caf4d28
AuthCode, AuthUtils updated and working
egarcia-flores Oct 10, 2021
0bdf9e5
Erased some comments and added some comments
egarcia-flores Oct 10, 2021
5dffcaf
Merge pull request #5 from DynasticINF/egarcia-flores/AuthCode_ticket
egarcia-flores Oct 10, 2021
b412749
Merge pull request #6 from DynasticINF/egarcia-flores/AuthCode_ticket
egarcia-flores Oct 10, 2021
265fc24
Post.ts
ekowt Oct 10, 2021
3d64d38
Ticket 3 Post Model
ekowt Oct 12, 2021
e839421
First Commit :)
CSCT Oct 13, 2021
f86f791
Merge pull request #7 from CSCT/Colby/first-commit
CSCT Oct 13, 2021
f9ff359
Commit before pull
Jeremy524 Oct 14, 2021
b78c830
commiting changes after pull
Jeremy524 Oct 14, 2021
60e09db
Ticket 5: Completed
Jeremy524 Oct 14, 2021
e96d1b4
Merge pull request #8 from DynasticINF/Jeremiah/5
DynasticINF Oct 14, 2021
fd477eb
Delete .env.devolopment
DynasticINF Oct 14, 2021
4704959
Revert "AuthCode, AuthUtils updated and working"
egarcia-flores Oct 16, 2021
701b870
Merge pull request #9 from DynasticINF/revert-5-egarcia-flores/AuthCo…
egarcia-flores Oct 16, 2021
eba2248
trying to re push all my week 1 work because it had been deleted
egarcia-flores Oct 16, 2021
178ef09
Merge branch 'main' into Week1_ticket1
egarcia-flores Oct 16, 2021
8289b36
Merge pull request #10 from DynasticINF/Week1_ticket1
egarcia-flores Oct 16, 2021
2f63a31
Ticket 6 Commit
tgthomp27 Oct 16, 2021
6b7a896
Merge pull request #11 from DynasticINF/Tarah_Thompson/ticket6
tgthomp27 Oct 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a private social network for pods to stay connected with each other after the program.

## Collaborators

Jeremiah Anim / CS @ JWU '23
Lorena Burrell / CS @ GSU
Ekow Thompson / CS @UA
Tarah Thompson / CS @GT
Edwin Garcia-Flores / CpE @UC'22
Colby Thompson / CS @ Cornell '23
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.4",
"ts-node-dev": "^1.1.6",
"typescript": "^4.3.2"
"typescript": "^4.4.3"
}
}
3 changes: 2 additions & 1 deletion src/models/AuthCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import AuthCode from './AuthCode';
* npm run test AuthCode
* - Delete this comment.
*/
describe.skip('Model: AuthCode', () => {

describe('Model: AuthCode', () => {
test('Should auto generate an OTP for value.', async () => {
// Even though we don't specify a value for the OTP code, it should
// automatically generate.
Expand Down
15 changes: 12 additions & 3 deletions src/models/AuthCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ const authCodeSchema: Schema<AuthCodeDocument> = new Schema<AuthCodeDocument>(
* - Add comment(s) to explain your work.
*/
{
// Here's an example of how to add a field to the schema.
exampleField: { required: true, type: String, unique: false }

// phoneNumber: { required: true, type: String, unique: true },
phoneNumer: {required: true, type: String, unique: true},
// value: { default: AuthUtils.generateOTP, required: true, type: Number }
value: { default: AuthUtils.generateOTP, required: true, type: Number }
},
{ timestamps: true }
// { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
{ timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }

);

/**
Expand All @@ -54,6 +59,10 @@ const authCodeSchema: Schema<AuthCodeDocument> = new Schema<AuthCodeDocument>(
* to the code you found in a comment.
* */


// pulled from ColorStack notion helpful info
authCodeSchema.index({ createdAt: 1 }, { expireAfterSeconds: 60 * 5 });

const AuthCode: mongoose.Model<AuthCodeDocument> =
mongoose.model<AuthCodeDocument>(Model.AUTH_CODE, authCodeSchema);

Expand Down
24 changes: 10 additions & 14 deletions src/models/Comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,21 @@ export type CommentDocument = Document<{}, {}, IComment> & IComment;

const commentSchema: Schema<CommentDocument> = new Schema<CommentDocument>(
{
/**
* (5.02) TODO:
* - Create the schema for the Comments that we'll save in the database using
* the interface above as a reference.
* - Delete this comment and the example field.
* - Add comment(s) to explain your work.
*/
exampleField: { ref: Model.USER, required: false, type: ID, unique: false }
author: { ref: Model.USER, required: true, type: ID },
content: { required: true, type: String },
post: { ref: Model.POST, required: true, type: ID }
},
{ timestamps: true }
);

commentSchema.pre('save', function () {
commentSchema.pre('save', async function () {
if (this.isNew) {
/**
* TODO: (6.05)
* - Send a text to the author of the post notifying them that a podmate
* commented under it!
*/
const post: PostDocument = await Post.findById(this.post);
const postAuthor: UserDocument = await User.findById(post.author);
TextService.sendText({
message: 'One of your podmates commented on your post!',
to: postAuthor.phoneNumber
});
}
});

Expand Down
35 changes: 12 additions & 23 deletions src/models/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@ import { CommentDocument } from './Comment';
import { ReactionDocument } from './Reaction';
import User, { UserDocument } from './User';

/**
* TODO: (3.01)
* - Read this enum.
* - Delete this comment.
*/
export enum PostType {
HELP = 'HELP', // Asking for help...
TIL = 'TIL', // Today I learned...
WIN = 'WIN' // Sharing a win...
}

/**
* TODO: (3.02)
* - Read this interface.
* - Delete this comment once you've done so.
*/
interface IPost extends BaseModel {
/**
* User that is associated with the creation of the post.
Expand Down Expand Up @@ -55,14 +45,8 @@ export type PostDocument = Document<{}, {}, IPost> & IPost;

const postSchema: Schema<PostDocument> = new Schema<PostDocument>(
{
/**
* TODO: (3.03)
* - Create the schema for the Posts that we'll save in the database using
* the interface above as a reference.
* - Delete this comment and the example field.
* - Add comment(s) to explain your work.
*/
exampleField: { required: true, type: String }
author: { ref: Model.USER, required: true, type: ID },
content: { required: true, type: String }
},
{
timestamps: true,
Expand All @@ -74,11 +58,16 @@ const postSchema: Schema<PostDocument> = new Schema<PostDocument>(
const sendNotification = async function (
author: PopulatedDoc<UserDocument, {} & string>
) {
/**
* TODO: (6.04)
* - Send a text to all the users except for the author of this post letting
* them know that their podmate shared an update!
*/
const allUSers: UserDocument[] = await User.find();
allUSers.map((user) => {
if (user != author) {
TextService.sendText( {
message: 'One of your podmates shared an update!',
to: user.phoneNumber

});
}
});
};

postSchema.pre('save', function () {
Expand Down
8 changes: 7 additions & 1 deletion src/routes/HelloWorldRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export default class HelloWorldRoute extends BaseRoute<HelloWorldResult> {
async content(): Promise<HelloWorldResult> {
return {
message: 'Looks like the server is up and running!',
podmates: []
podmates: [
'Lorena Burrell',
'Jeremiah Anim',
'Ekow Thompson',
'Tarah Thompson',
'Edwin Garcia-Flores'
]
};
}
}
10 changes: 2 additions & 8 deletions src/services/TextService.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { APP } from '../utils/constants';
import TextService, { client } from './TextService';

/**
* TODO: (6.05)
* - Remove the ".skip" from the following function.
* - Go to your terminal and run the following command:
* npm run test TextService
* - Delete this comment.
*/
describe.skip('TextService.sendText()', () => {

describe('TextService.sendText()', () => {
// Mock the twilio "sending" functionality.
client.messages.create = jest.fn();

Expand Down
7 changes: 7 additions & 0 deletions src/services/TextService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ const sendText = async ({ message, to }: SendTextArgs): Promise<boolean> => {

try {
// Send the text
await client.messages.create({
body: message,
from: APP.TWILIO_PHONE_NUMBER,
to: to

});
} catch (e) {
// What should be return if sending the text was unsuccessful?
return false;
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/AuthUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const generateOTP = (): number => {
* - Make sure tall the tests pass.
* - Delete this comment.
*/
return 123456;
return Math.floor(100000 + Math.random() * 900000);

};

/**
Expand Down