Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #523

Merged
merged 6 commits into from
Sep 10, 2024
Merged

Dev #523

Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "TAMU SHPE",
"slug": "TAMU-SHPE",
"version": "1.0.14",
"version": "1.0.15",
"owner": "tamu-shpe",
"orientation": "portrait",
"icon": "./assets/icon.png",
Expand Down Expand Up @@ -54,7 +54,7 @@
"permissions": [
"android.permission.RECORD_AUDIO"
],
"versionCode": 85,
"versionCode": 87,
"userInterfaceStyle": "automatic",
"config": {
"googleMaps": {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ export { notifyUpcomingEvents, sendNotificationOfficeHours, sendNotificationMemb
export { updateUserPoints, updateAllUserPoints, scheduledUpdateAllPoints } from "./pointSheet";
export { updateCommitteeCount, scheduleCommitteeCount } from "./committees";
// export { resetOfficeScheduler } from "./officeReset";
export { isUserInBlacklist } from "./restriction";
export { resetOfficeOnCall } from "./officeReset";
export { zipResume } from "./resume";
export { updateUserRole } from "./roles";
export { checkUsernameUniqueness } from "./checkUsername";
export { eventSignIn, eventSignOut, eventLogDelete, addInstagramPoints } from "./events";
export { isUserInBlacklist } from "./restriction";
export { calculateMOTM } from "./points";
export { scheduledFirestoreExport, httpFirestoreExport, resetPointsWithPassword } from "./backup"
2 changes: 1 addition & 1 deletion functions/src/pushNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const sendNotificationResumeConfirm = functions.https.onCall(async (data,
});


export const notifyUpcomingEvents = functions.pubsub.schedule('every 5 minutes').onRun(async (context) => {
export const notifyUpcomingEvents = functions.pubsub.schedule('every 30 minutes').onRun(async (context) => {
console.log('Running Event Notification Sent');
const now = new Date();
const oneHourLater = new Date(now.getTime() + 60 * 60 * 1000);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shpe-app",
"version": "1.0.14",
"version": "1.0.15",
"scripts": {
"start": "npx expo start --dev-client",
"test": "jest --coverage=true --verbose --bail --config ./jest.config.ts",
Expand Down
61 changes: 0 additions & 61 deletions src/api/firebaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,67 +1462,6 @@ export const getMOTM = async () => {
// Misc. Utilities
// ============================================================================

export const getWatchlist = async () => {
const docRef = doc(db, "restrictions/watchlist");
const docSnap = await getDoc(docRef);
return docSnap.exists() ? docSnap.data().list : [];
};

export const getBlacklist = async () => {
const docRef = doc(db, "restrictions/blacklist");
const docSnap = await getDoc(docRef);
return docSnap.exists() ? docSnap.data().list : [];
};


export const addToWatchlist = async (userToAdd: PublicUserInfo) => {
const currentWatchlist = await getWatchlist() || [];

if (!currentWatchlist.some((user: PublicUserInfo) => user.uid === userToAdd.uid)) {
const updatedWatchlist = [...currentWatchlist, userToAdd];
await setDoc(doc(db, "restrictions/watchlist"), { list: updatedWatchlist }, { merge: true });
}
};

export const addToBlacklist = async (userToAdd: PublicUserInfo) => {
const currentBlacklist = await getBlacklist() || [];

if (!currentBlacklist.some((user: PublicUserInfo) => user.uid === userToAdd.uid)) {
const updatedBlacklist = [...currentBlacklist, userToAdd];
await setDoc(doc(db, "restrictions/blacklist"), { list: updatedBlacklist }, { merge: true });
}
};

export const removeFromWatchlist = async (userToRemove: PublicUserInfo) => {
const currentWatchlist = await getWatchlist() || [];

const updatedWatchlist = currentWatchlist.filter((user: PublicUserInfo) => user.uid !== userToRemove.uid);

await setDoc(doc(db, "restrictions/watchlist"), { list: updatedWatchlist }, { merge: true });
};

export const removeFromBlacklist = async (userToRemove: PublicUserInfo) => {
const currentBlacklist = await getBlacklist() || [];

const updatedBlacklist = currentBlacklist.filter((user: PublicUserInfo) => user.uid !== userToRemove.uid);

await setDoc(doc(db, "restrictions/blacklist"), { list: updatedBlacklist }, { merge: true });
};

export const isUserInBlacklist = async (uid: string): Promise<boolean> => {
const blacklistDocRef = doc(db, "restrictions/blacklist");
const docSnap = await getDoc(blacklistDocRef);

if (docSnap.exists()) {
const blacklist = docSnap.data().list;
return blacklist.some((user: PublicUserInfo) => user.uid === uid);
} else {
// Blacklist document does not exist or has no data
return false;
}
};


export const submitFeedback = async (feedback: string, userInfo: User) => {
try {
await addDoc(collection(db, 'feedback'), {
Expand Down
2 changes: 0 additions & 2 deletions src/navigation/HomeStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import AdminDashboard from "../screens/admin/AdminDashboard";
import MOTMEditor from "../screens/admin/MOTMEditor";
import ResumeDownloader from "../screens/admin/ResumeDownloader";
import LinkEditor from "../screens/admin/LinkEditor";
import RestrictionsEditor from "../screens/admin/RestrictionsEditor";
import MemberSHPEConfirm from "../screens/admin/MemberSHPEConfirm";
import ResumeConfirm from "../screens/admin/ResumeConfirm";
import ShirtConfirm from "../screens/admin/ShirtConfirm";
Expand Down Expand Up @@ -54,7 +53,6 @@ const HomeStack = () => {
<Stack.Screen name="MOTMEditor" component={MOTMEditor} />
<Stack.Screen name="ResumeDownloader" component={ResumeDownloader} />
<Stack.Screen name="LinkEditor" component={LinkEditor} />
<Stack.Screen name="RestrictionsEditor" component={RestrictionsEditor} />
<Stack.Screen name="MemberSHPEConfirm" component={MemberSHPEConfirm} />
<Stack.Screen name="ResumeConfirm" component={ResumeConfirm} />
<Stack.Screen name="ShirtConfirm" component={ShirtConfirm} />
Expand Down
26 changes: 0 additions & 26 deletions src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,6 @@ const RootNavigator = () => {
// }
// }, [userInfo]);


useEffect(() => {
const handleBannedUser = async () => {
if (!auth.currentUser?.uid) {
return;
}

const functions = getFunctions();
const isUserInBlacklist = httpsCallable<{ uid: string }, { isInBlacklist: boolean }>(functions, 'isUserInBlacklist');
try {
const checkBlackListResponse = await isUserInBlacklist({ uid: auth.currentUser?.uid! });

if (checkBlackListResponse.data.isInBlacklist) {
signOutUser(true);
alert("You have been banned from the app");
return;
}
} catch (error) {
console.error('Error during user authentication:', error);
}

}

handleBannedUser();
}, [auth.currentUser?.uid])

if (userLoading) {
return <RenderUserLoading />;
}
Expand Down
19 changes: 1 addition & 18 deletions src/screens/admin/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,7 @@ const AdminDashboard = ({ navigation }: NativeStackScreenProps<HomeStackParams>)
<Text className='text-xl font-semibold text-black text-center'>App Feedback</Text>
</TouchableOpacity>
</View>
<View className='flex-row justify-between mt-4'>
<TouchableOpacity
className={`bg-secondary-blue-2 items-center justify-center h-20 rounded-lg w-[48%]`}
style={{
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
onPress={() => navigation.navigate('RestrictionsEditor')}
>
<Text className='text-xl font-semibold text-black text-center'>App Restriction</Text>
</TouchableOpacity>
</View>


<Text className={`mt-8 font-bold text-2xl ${darkMode ? "text-white" : "text-black"}`}>Developer Tools</Text>
<View>
Expand Down
Loading
Loading