famedly / matrix-dart-sdk

Matrix SDK written in pure Dart.
GNU Affero General Public License v3.0
62 stars 33 forks source link

Invited cant see messages because of prev_batch null #1756

Open MichalNemec opened 7 months ago

MichalNemec commented 7 months ago

Checklist

In which Project did the bug appear?

Other

If you selected \"Other\" as Project, please enter in which project the bug occurred.

SDK

On which platform did the bug appear?

Android, iOS

SDK Version

29d982b

Describe the problem caused by this bug

im using this for private conversation:

.startDirectChat(
        mxId,
        preset: CreateRoomPreset.trustedPrivateChat,
        enableEncryption: false,
        initialState: [
          StateEvent(
            content: {
              'history_visibility': HistoryVisibility.worldReadable.text, //wanted joined, but still same issue
            },
            type: EventTypes.HistoryVisibility,
          ),
        ],
      )

When creator sends a message in that room, then invitee sees username and no message, upon clicking on that conversation, i get error: Tried to request history without a prev_batch token

I need to see messages before accepting the conversation to prevent spam.

upon accepting conversation, i see messages.

Steps To Reproduce

  1. invite someone
  2. see no message
  3. cannot see any events in timeline
  4. exception

Screenshots or Logs

No response

Security related

No response

krille-chan commented 7 months ago

I need to see messages before accepting the conversation to prevent spam.

This is not possible. As you can see in the spec here the matrix protocol doesn't allow taking a look into the timeline. However it is possible to set the reason field when sending an invite. Be aware that this would be not end to end encrypted

MichalNemec commented 7 months ago

I used element app: 1) created a room 2) made the room public 3) "You made future room history visible to anyone." 4) "You changed the room name to PUBLIC" 5) "You changed the topic to "?" 6) "You invited [testing user from matrix-dart-sdk]" 7) sent "hello" message 8) click in flutter app on invite 9) see empty screen, no messages.

The only thing i see is a status message (joined the chat) from event.calcLocalizedBodyFallback(i18n, withSenderNamePrefix: true),

PhantomRay commented 6 months ago

I don't use reason, but something similar:

 var creationContent = <String, Object?>{};
    creationContent['request_info'] = requestInfo;

    var roomId = await _client.createRoom(
      invite: [matrixUserId],
      isDirect: true,
      preset: CreateRoomPreset.trustedPrivateChat,
      initialState: initialState,
      powerLevelContentOverride: null,
      creationContent: creationContent,
    );

Then you can retrieve it in RoomCreate event