-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add can't send email warning for users that can not receiv… (#176)
* ✨ Show detailed error message when template saving fails * ✨ Add language picker to comm templates * 💄 Improved UI changes * ✨ Better empty message * ♻️ Refactor language name getter * 🧹 Cleanup * ✨ Add can't send email warning for users that can not receive emails * ✨ Move allowed domain list to env var * ✨ Change message in warning
- Loading branch information
Showing
4 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,33 @@ | ||
import { DOMAINS_ALLOWING_EMAIL_COMMUNICATION } from '@/lib/constants' | ||
import { resolveDidDocData } from '@/lib/identity' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export const useEmailRecipientStatus = ( | ||
did: string, | ||
): { isLoading: boolean; error: any; cantReceive: boolean } => { | ||
const { data, isLoading, error } = useQuery({ | ||
queryKey: ['email-capability-check', did], | ||
queryFn: async () => { | ||
const response = await resolveDidDocData(did) | ||
if (!response?.services) { | ||
return false | ||
} | ||
|
||
const pdsEndpoint = response.services['atproto_pds']?.endpoint | ||
if (!pdsEndpoint) { | ||
return false | ||
} | ||
|
||
return DOMAINS_ALLOWING_EMAIL_COMMUNICATION.some((domain) => { | ||
return !!domain && pdsEndpoint.endsWith(domain) | ||
}) | ||
}, | ||
}) | ||
|
||
return { | ||
isLoading, | ||
error, | ||
// we only know for sure that the recipient can't receive emails if the result of the query is false is false | ||
cantReceive: data === false, | ||
} | ||
} |
This file contains 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
This file contains 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