We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When a content type fallback is set as undefined, Decoded message's fallback is ""
Should be undefined
test('register and use custom content types', async () => { const bob = await Client.createRandom({ env: 'local', codecs: [new NumberCodec()], }) const alice = await Client.createRandom({ env: 'local', // codecs: [new NumberCodec()], }) bob.register(new NumberCodec()) const bobConvo = await bob.conversations.newConversation(alice.address) const aliceConvo = await alice.conversations.newConversation(bob.address) await bobConvo.send(12, { contentType: ContentTypeNumber }) const messages = await aliceConvo.messages() assert(messages.length === 1, 'did not get messages') const message = messages[0] let messageContent = undefined; try { messageContent = message.content() } catch (err) { messageContent = message.fallback console.log('Setting fallback', typeof message.fallback, {messageContent}) } assert( messageContent !== "", 'did not get content properly: ' + JSON.stringify(messageContent) ) return true })
class NumberCodec implements JSContentCodec<NumberRef> { contentType = ContentTypeNumber // a completely absurd way of encoding number values encode(content: NumberRef): EncodedContent { return { type: ContentTypeNumber, parameters: { test: 'test', }, content: new TextEncoder().encode(JSON.stringify(content)), } } decode(encodedContent: EncodedContent): NumberRef { if (encodedContent.parameters.test !== 'test') { throw new Error(`parameters should parse ${encodedContent.parameters}`) } const contentReceived = JSON.parse( new TextDecoder().decode(encodedContent.content) ) as NumberRef return contentReceived } fallback(content: NumberRef): string | undefined { return undefined } }
The text was updated successfully, but these errors were encountered:
Is this also the case for non-custom content types? I thought you were seeing it for read receipts as well?
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Describe the bug
When a content type fallback is set as undefined, Decoded message's fallback is ""
Expected behavior
Should be undefined
Steps to reproduce the bug
The text was updated successfully, but these errors were encountered: