-
-
Notifications
You must be signed in to change notification settings - Fork 449
Move Notification Logic from Discussion Store to Firebase Functions #3620
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
Closed
goratt12
wants to merge
14
commits into
ONEARMY:master
from
goratt12:3563-move-discussion-notifications-to-functions
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ed981c7
feat(functions): move notification logic from discussion store to fir…
goratt12 37ec4b9
fix(functions): removed old tests
goratt12 e847de0
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 a6fa28d
fix(functions): fixed lint issues due to merge
goratt12 570d807
fix(functions): changed IDiscussionComment to IComment
goratt12 a770ef7
fix(functions): addressed change requests
goratt12 990203b
feat(functions): prevent duplicate notifications
goratt12 d523fef
fix(functions): comment out notification tests in discussion specs
goratt12 13e4afe
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 471917c
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
goratt12 2c64f01
fix(functions): fix requested changes
goratt12 3a9817c
fix(functions): fixed lint issues
goratt12 fe8a972
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
benfurber 2997735
Merge branch 'master' into 3563-move-discussion-notifications-to-func…
benfurber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { getDiscussionCollectionName, randomID } from './db.utils' | ||
|
||
describe('getDiscussionCollectionName', () => { | ||
it('should return "questions" when sourceType is "question"', () => { | ||
const result = getDiscussionCollectionName('question') | ||
expect(result).toBe('questions') | ||
}) | ||
|
||
it('should return "howtos" when sourceType is "howto"', () => { | ||
const result = getDiscussionCollectionName('howto') | ||
expect(result).toBe('howtos') | ||
}) | ||
|
||
it('should return null when sourceType is unrecognized', () => { | ||
const result = getDiscussionCollectionName('unknown') | ||
expect(result).toBe(null) | ||
}) | ||
it('should return null when sourceType is an empty string', () => { | ||
const result = getDiscussionCollectionName('') | ||
expect(result).toBeNull() | ||
}) | ||
|
||
it('should return "research" when sourceType is "researchUpdate"', () => { | ||
const result = getDiscussionCollectionName('researchUpdate') | ||
expect(result).toBe('research') | ||
}) | ||
}) | ||
|
||
describe('randomID', () => { | ||
// generates a string of length 20 | ||
it('should generate a string of length 20 and include only alphanumeric characters', () => { | ||
const id = randomID() | ||
const alphanumericRegex = /^[a-zA-Z0-9]+$/ | ||
expect(id).toHaveLength(20) | ||
expect(alphanumericRegex.test(id)).toBe(true) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export type DiscussionEndpoints = 'howtos' | 'research' | 'questions' | ||
|
||
/** | ||
* Function used to determine the discussion collection name based on the source type. | ||
*/ | ||
export const getDiscussionCollectionName = ( | ||
sourceType: string, | ||
): DiscussionEndpoints | null => { | ||
switch (sourceType) { | ||
case 'question': | ||
return 'questions' | ||
case 'howto': | ||
return 'howtos' | ||
case 'researchUpdate': | ||
return 'research' | ||
default: | ||
return null | ||
} | ||
} | ||
|
||
/** | ||
* Function used to generate random ID in same manner as firestore | ||
*/ | ||
export const randomID = () => { | ||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | ||
let autoId = '' | ||
for (let i = 0; i < 20; i++) { | ||
autoId += chars.charAt(Math.floor(Math.random() * chars.length)) | ||
} | ||
return autoId | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './auth.utils' | ||
export * from './data.utils' | ||
export * from './file.utils' | ||
export * from './db.utils' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.