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

enmeshed: Remove welcome message #1773

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
49 changes: 0 additions & 49 deletions packages/server/src/internals/server/enmeshed-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ function createEnmeshedWebhookMiddleware(
}

if (!sessionId) {
await sendWelcomeMessage({ relationship: data, client })
await sendAttributesChangeRequest({ relationship: data, client })
}
}
Expand Down Expand Up @@ -512,54 +511,6 @@ function createEnmeshedWebhookMiddleware(
}
}

/**
* Sends a welcome message with a test file attachment to be saved within the users' data wallet
*/
async function sendWelcomeMessage({
relationship,
client,
}: {
relationship: Relationship
client: ConnectorClient
}): Promise<void> {
const expiresAt = new Date()
expiresAt.setHours(expiresAt.getHours() + 1)
const uploadFileResponse = await client.files.uploadOwnFile({
title: 'Serlo Testdatei',
description: 'Test file created by Serlo',
file: Buffer.from(
'<html><head><title>Serlo Testdatei</title></head><body><p>Hello World! - Dies ist eine Testdatei.</p></body></html>',
),
filename: 'serlo-test.html',
expiresAt: expiresAt.toISOString(),
})

if (uploadFileResponse.isError) {
handleConnectorError({
error: uploadFileResponse.error,
message: 'Failed to upload file in welcome message',
})
}

const sendMessageResponse = await client.messages.sendMessage({
recipients: [relationship.peer],
content: {
'@type': 'Mail',
to: [relationship.peer],
subject: 'Danke für dein Vertrauen.',
body: 'Hallo!\nDanke für deine Anfrage, wir freuen uns über dein Vertrauen.\nDein Serlo-Team',
},
attachments: [uploadFileResponse.result.id],
})

if (sendMessageResponse.isError) {
handleConnectorError({
error: sendMessageResponse.error,
message: 'Failed to upload file in welcome message',
})
}
}

/**
* Requests user to change and share attributes in data wallet
* Attributes will be sent to connector webhook after confirmation
Expand Down