Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshGurnani committed Oct 29, 2023
1 parent 36656e7 commit be32c74
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 105 deletions.
18 changes: 9 additions & 9 deletions ALUM/ALUM/ALUMApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import Firebase
import UserNotifications
import FirebaseMessaging

//class AppDelegate: NSObject, UIApplicationDelegate {
// class AppDelegate: NSObject, UIApplicationDelegate {
// func application(_ application: UIApplication,
// didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
// FirebaseApp.configure()
// return true
// }
//}
// }

extension View {
func dismissKeyboardOnDrag() -> some View {
Expand All @@ -42,12 +42,12 @@ struct ALUMApp: App {
}
}


class AppDelegate: NSObject, UIApplicationDelegate {
let gcmMessageIDKey = "gcm.message_id"
@ObservedObject var currentUser: CurrentUserModel = CurrentUserModel.shared

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
FirebaseApp.configure()

Messaging.messaging().delegate = self
Expand Down Expand Up @@ -84,7 +84,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {
}
}


extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print("did receive FCM Token")
Expand All @@ -96,12 +95,13 @@ extension AppDelegate: MessagingDelegate {
}

@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
extension AppDelegate: UNUserNotificationCenterDelegate {

// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
withCompletionHandler completionHandler:
@escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo

if let messageID = userInfo[gcmMessageIDKey] {
Expand Down
4 changes: 2 additions & 2 deletions ALUM/ALUM/Models/CurrentUserModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class CurrentUserModel: ObservableObject {
}
return userStatus
}

func sendFcmTokenHelper(fcmToken: String) {
Task {
do {
Expand All @@ -170,7 +170,7 @@ class CurrentUserModel: ObservableObject {
}
}
}

func sendFcmToken(fcmToken: String) async throws {
print(fcmToken)
print(self.uid)
Expand Down
114 changes: 56 additions & 58 deletions ALUM/ALUM/Services/APIConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ let developmentMode = false

// Firebase URL will not be updated very frequently because
// so your changes to backend will only reflect on localhost until deployed
/*
#if DEBUG
let baseURL = "http://127.0.0.1:3000"
#else
let baseURL = "https://firebaseapp-ozybc5bsma-uc.a.run.app"
#endif
*/
let baseURL = "http://100.115.53.55:3000"

struct URLString {
static let user = "\(baseURL)/user"
static let mentor = "\(baseURL)/mentor"
Expand Down Expand Up @@ -48,68 +46,68 @@ enum APIRoute {

var url: String {
switch self {
case .getSelf:
return [URLString.user, "me"].joined(separator: "/")
case .getMentor(let userId):
return [URLString.mentor, userId].joined(separator: "/")
case .getMentee(let userId):
return [URLString.mentee, userId].joined(separator: "/")
case .postMentor:
return URLString.mentor
case .postMentee:
return URLString.mentee
case .getNote(noteId: let noteId):
return [URLString.notes, noteId].joined(separator: "/")
case .patchNote(noteId: let noteId):
return [URLString.notes, noteId].joined(separator: "/")
case .getSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
case .getSessions:
return URLString.sessions
case .postSession:
return URLString.sessions
case .getCalendly:
return URLString.calendly
case .patchUser(let userId):
return [URLString.user, userId].joined(separator: "/")
case .deleteSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
case .patchSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
case .getSelf:
return [URLString.user, "me"].joined(separator: "/")
case .getMentor(let userId):
return [URLString.mentor, userId].joined(separator: "/")
case .getMentee(let userId):
return [URLString.mentee, userId].joined(separator: "/")
case .postMentor:
return URLString.mentor
case .postMentee:
return URLString.mentee
case .getNote(noteId: let noteId):
return [URLString.notes, noteId].joined(separator: "/")
case .patchNote(noteId: let noteId):
return [URLString.notes, noteId].joined(separator: "/")
case .getSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
case .getSessions:
return URLString.sessions
case .postSession:
return URLString.sessions
case .getCalendly:
return URLString.calendly
case .patchUser(let userId):
return [URLString.user, userId].joined(separator: "/")
case .deleteSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
case .patchSession(sessionId: let sessionId):
return [URLString.sessions, sessionId].joined(separator: "/")
}
}

var method: String {
switch self {
case .getSelf, .getMentee, .getMentor, .getNote, .getSession, .getSessions, .getCalendly:
return "GET"
case .postMentor, .postMentee, .postSession:
return "POST"
case .patchNote, .patchUser, .patchSession:
return "PATCH"
case .deleteSession:
return "DELETE"
case .getSelf, .getMentee, .getMentor, .getNote, .getSession, .getSessions, .getCalendly:
return "GET"
case .postMentor, .postMentee, .postSession:
return "POST"
case .patchNote, .patchUser, .patchSession:
return "PATCH"
case .deleteSession:
return "DELETE"
}
}

var requireAuth: Bool {
switch self {
case
.getSelf,
.getMentor,
.getMentee,
.getNote,
.patchNote,
.getSession,
.getSessions,
.postSession,
.getCalendly,
.patchUser,
.patchSession,
.deleteSession:
return true
case .postMentee, .postMentor:
return false
case
.getSelf,
.getMentor,
.getMentee,
.getNote,
.patchNote,
.getSession,
.getSessions,
.postSession,
.getCalendly,
.patchUser,
.patchSession,
.deleteSession:
return true
case .postMentee, .postMentor:
return false
}
}

Expand All @@ -127,7 +125,7 @@ enum APIRoute {

var successCode: Int {
switch self {
case .getSelf, .getMentor, .getMentee, .getNote, .patchNote,
case .getSelf, .getMentor, .getMentee, .getNote, .patchNote,
.getSession, .getSessions, .getCalendly, .patchUser, .deleteSession, .patchSession:
return 200 // 200 Ok
case .postMentor, .postMentee, .postSession:
Expand All @@ -140,7 +138,7 @@ enum APIRoute {
let errorMap: [Int: AppError]

switch self {
case .getSelf, .getMentor, .getMentee, .getNote, .patchNote,
case .getSelf, .getMentor, .getMentee, .getNote, .patchNote,
.getSession, .getSessions, .getCalendly, .patchUser,
.deleteSession, .patchSession:
errorMap = [
Expand All @@ -157,7 +155,7 @@ enum APIRoute {
400: AppError.internalError(.invalidRequest, message: message)
]
}

let error = errorMap[statusCode] ?? AppError.internalError(.unknownError, message: labeledMessage)
return error
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/errors/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class ServiceError extends CustomError {
static MENTOR_WAS_NOT_SAVED = new ServiceError(11, 404, MENTOR_WAS_NOT_SAVED);

static MENTEE_WAS_NOT_SAVED = new ServiceError(12, 404, MENTEE_WAS_NOT_SAVED);

static INVALID_ROLE_WAS_FOUND = new ServiceError(11, 404, INVALID_ROLE_WAS_FOUND);

static ERROR_DELETING_EVENT = new ServiceError(7, 404, ERROR_DELETING_EVENT);
Expand Down
36 changes: 21 additions & 15 deletions backend/src/routes/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ router.post(
}
const accessToken = mentor.personalAccessToken;
const data = await getCalendlyEventDate(req.body.calendlyURI, accessToken);
const startDate = new Date(2023, 0O5, 0O5, 17, 0, 0, 0);
const endDate = new Date(2023, 0O5, 0O5, 18, 0, 0, 0);
const startDate = new Date(2023, 0o5, 0o5, 17, 0, 0, 0);
const endDate = new Date(2023, 0o5, 0o5, 18, 0, 0, 0);

const session = new Session({
preSession: null,
Expand All @@ -80,7 +80,7 @@ router.post(
session.postSessionMentee = postMenteeNoteId._id;
session.postSessionMentor = postMentorNoteId._id;
await session.save();

await sendNotification(
"New session booked!",
"You have a new session with " + mentee.name + ". Check out your session details \u{1F60E}",
Expand All @@ -93,7 +93,7 @@ router.post(
". Fill out your pre-session notes now \u{1F60E}",
mentee.fcmToken
);

return res.status(201).json({
sessionId: session._id,
mentorId: session.mentorId,
Expand Down Expand Up @@ -327,14 +327,18 @@ router.patch(
await Session.findByIdAndUpdate(sessionId, { $set: updates }, { new: true });
await sendNotification(
"A session has been rescheduled",
"Your upcoming session with " + mentor.name + " has been rescheduled! Check out your new session details.",
"Your upcoming session with " +
mentor.name +
" has been rescheduled! Check out your new session details.",
mentee.fcmToken
)
);
await sendNotification(
"A session has been rescheduled",
"" + mentee.name + " has rescheduled your upcoming session! Check out your session details.",
"" +
mentee.name +
" has rescheduled your upcoming session! Check out your session details.",
mentor.fcmToken
)
);
return res.status(200).json({
message: "Successfuly updated the session!",
});
Expand Down Expand Up @@ -377,23 +381,25 @@ router.delete(
"A session has been cancelled.",
"Your session with " + mentor.name + " has been cancelled.",
mentee.fcmToken
)
);
await sendNotification(
"A session has been cancelled.",
"" + mentee.name + " has cancelled your upcoming session.",
mentor.fcmToken
)
} else if (role === "mentor") {
);
} else if (role === "mentor") {
await sendNotification(
"A session has been cancelled.",
"Your session with " + mentee.name + " has been cancelled.",
mentor.fcmToken
)
await sendNotification (
);
await sendNotification(
"A session has been cancelled.",
"" + mentor.name + " has cancelled your upcoming session. \u{1F494} Reschedule to save your pre-session notes.",
"" +
mentor.name +
" has cancelled your upcoming session. \u{1F494} Reschedule to save your pre-session notes.",
mentee.fcmToken
)
);
}
return res.status(200).json({
message: "calendly successfully cancelled, notes deleted, session deleted.",
Expand Down
11 changes: 9 additions & 2 deletions backend/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import mongoose from "mongoose";
import { validateReqBodyWithCake } from "../middleware/validation";
import { Mentee, Mentor, Pairing } from "../models";
import { createUser } from "../services/auth";
import { getMenteeId, getMentorId, updateMentor, updateMentee, updateMentorFCMToken, updateMenteeFCMToken } from "../services/user";
import {
getMenteeId,
getMentorId,
updateMentor,
updateMentee,
updateMentorFCMToken,
updateMenteeFCMToken,
} from "../services/user";
import {
CreateMenteeRequestBodyCake,
CreateMentorRequestBodyCake,
Expand Down Expand Up @@ -457,7 +464,7 @@ router.patch(
next(e);
}
}
)
);

/**
* * This route will update a mentor's values.
Expand Down
16 changes: 10 additions & 6 deletions backend/src/services/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,23 @@ async function updateNotes(updatedNotes: UpdateNoteDetailsType[], documentId: st
sessionDoc.preSessionCompleted = true;
await sendNotification(
"Pre-session update!",
"Looks like " + mentee.name + " has some questions for you. Check out " + mentee.name + "'s pre-session notes.",
"Looks like " +
mentee.name +
" has some questions for you. Check out " +
mentee.name +
"'s pre-session notes.",
mentor.fcmToken
);
}
else if (noteDoc.type === "postMentor") {
} else if (noteDoc.type === "postMentor") {
sessionDoc.postSessionMentorCompleted = true;
await sendNotification(
"Post-session update!",
"" + mentor.name + " has updated their post-session notes. Check out what they had to say!",
"" +
mentor.name +
" has updated their post-session notes. Check out what they had to say!",
mentee.fcmToken
);
}
else if (noteDoc.type === "postMentee") sessionDoc.postSessionMenteeCompleted = true;
} else if (noteDoc.type === "postMentee") sessionDoc.postSessionMenteeCompleted = true;
if (missedNote && sessionDoc.missedSessionReason == null)
sessionDoc.missedSessionReason = missedReason;
await sessionDoc.save();
Expand Down
Loading

0 comments on commit be32c74

Please sign in to comment.