MCPcopy Index your code
hub / github.com/simstudioai/sim / isUnsubscribed

Function isUnsubscribed

apps/sim/lib/messaging/email/unsubscribe.ts:152–176  ·  view source on GitHub ↗
(
  email: string,
  emailType: 'all' | 'marketing' | 'updates' | 'notifications' = 'all'
)

Source from the content-addressed store, hash-verified

150 * Check if user has unsubscribed from a specific email type
151 */
152export async function isUnsubscribed(
153 email: string,
154 emailType: 'all' | 'marketing' | 'updates' | 'notifications' = 'all'
155): Promise<boolean> {
156 try {
157 const preferences = await getEmailPreferences(email)
158 if (!preferences) return false
159
160 if (preferences.unsubscribeAll) return true
161
162 switch (emailType) {
163 case 'marketing':
164 return preferences.unsubscribeMarketing || false
165 case 'updates':
166 return preferences.unsubscribeUpdates || false
167 case 'notifications':
168 return preferences.unsubscribeNotifications || false
169 default:
170 return false
171 }
172 } catch (error) {
173 logger.error('Error checking unsubscribe status:', error)
174 return false
175 }
176}
177
178/**
179 * Unsubscribe user from all emails

Callers 2

shouldSkipForUnsubscribeFunction · 0.90

Calls 2

getEmailPreferencesFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected