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

MatrixEvent.getRoomId() can return undefined #2035

Open
jaller94 opened this issue Nov 23, 2021 · 2 comments
Open

MatrixEvent.getRoomId() can return undefined #2035

jaller94 opened this issue Nov 23, 2021 · 2 comments

Comments

@jaller94
Copy link

I've lost some hours trusting the TypeScript annotation.

The return type should say string|undefined.

/**
* Get the room_id for this event. This will return <code>undefined</code>
* for <code>m.presence</code> events.
* @return {string} The room ID, e.g. <code>!cURbafjkfsMDVwdRDQ:matrix.org
* </code>
*/
public getRoomId(): string {

btw. I didn't get this on a m.presence but on a m.bad.encrypted:

MatrixEvent {
  _events: [Object: null prototype] {
    'Event.decrypted': [ [Function: forSource], [Function] ],
    'Event.replaced': [Function: forSource]
  },
  _eventsCount: 2,
  _maxListeners: undefined,
  event: {
    content: {
      algorithm: 'm.olm.v1.curve25519-aes-sha2',
      sender_key: '8LgWTZ5yFIawz80ylkAl1Mc9BX1oUZGAAAl3z0E7lXM',
      ciphertext: [Object]
    },
    type: 'm.room.encrypted',
    sender: '@jaller94:localhost'
  },
  pushActions: { notify: true, tweaks: { highlight: false } },
  _replacingEvent: null,
  _localRedactionEvent: null,
  _isCancelled: false,
  clearEvent: {
    type: 'm.room.message',
    content: {
      msgtype: 'm.bad.encrypted',
      body: '** Unable to decrypt: Not included in recipients **'
    }
  },
  senderCurve25519Key: null,
  claimedEd25519Key: null,
  forwardingCurve25519KeyChain: [],
  untrusted: false,
  _decryptionPromise: null,
  retryDecryption: false,
  txnId: null,
  thread: null,
  localTimestamp: NaN,
  sender: null,
  target: null,
  status: null,
  error: null,
  forwardLooking: true,
  verificationRequest: null,
  reEmitter: ReEmitter { target: [Circular *1] },
  [Symbol(kCapture)]: false
}
@ShadowJonathan
Copy link
Contributor

This sounds more like a bug on m.bad.encrypted's side than a typescript type omission.

@jaller94
Copy link
Author

Still, the JSDoc of the method says:

Get the room_id for this event. This will return undefined for m.presence events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants