Skip to content

Commit

Permalink
refactor(enmeshed): remove welcome message since it is broken and
Browse files Browse the repository at this point in the history
it is more code to be maintained.
  • Loading branch information
hugotiburtino committed Oct 16, 2024
1 parent 6c102f5 commit e5b5c2c
Showing 1 changed file with 0 additions and 49 deletions.
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

0 comments on commit e5b5c2c

Please sign in to comment.