Skip to content

fix export display bug#641

Merged
rusq merged 4 commits intomasterfrom
export-source
Mar 9, 2026
Merged

fix export display bug#641
rusq merged 4 commits intomasterfrom
export-source

Conversation

@rusq
Copy link
Copy Markdown
Owner

@rusq rusq commented Mar 8, 2026

When "viewing" exports, the self-user chat was displayed as <external> due to
flawed logic of except that would fail to assign the "self" user to the
conversation.user field.

Gory details

The dm chat entry in export's dms.json would have a slice of users
participating in DM, such as:

[
  {
    "id": "DHYNUJ00Y", // conversation ID
    "created": 1555493778,
    "members": [       // participants
      "UHSD97ZA5",     // this is you.
      "UABCDEFGH"      // this is someone else.
    ]
  }
]

To determine the user ID to assign to a DM conversation, the logic would:

  1. try to determine current user IDs by scanning through all DMs
    and finding the "most frequent user" ID.
  2. Then, to assign the users to other DMs, it would pick the first user in the
    slice, that is NOT the user discovered on step 1.

For chats with others, it would correctly return the User ID of the "other"
participant. For example, for the payload in the beginning of this section, it
would return "UABCDEFGH"

The chat with "yourself" looks like this in the export's dms.json:

[
  {
    "id": "DHYNUJ00Y",
    "created": 1555493778,
    "members": [
      "UHSD97ZA5",
      "UHSD97ZA5"
    ]
  }
]
  • Step 1 would discover that the most frequent user is UHSD97ZA5.
  • Step 2 would exclude this user and return an empty string.

As a result, the conversation would have an empty User ID and would not display
properly in the viewer.

Thank you, you're welcome, come again.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an export viewer display bug where self-DM conversations could render as <external> due to the IM User field being left empty when both DM members are the current user.

Changes:

  • Adjust DM-to-channel conversion to ensure self-DMs resolve a non-empty Conversation.User.
  • Extend the except helper with a fallback index parameter to handle the self-DM member list case.
  • Update/add unit tests for mostFrequentMember and except to cover the self-chat scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
internal/structures/index.go Updates DM user selection logic via except(..., 1) and extends except behavior/docs to avoid empty IM user IDs.
internal/structures/index_test.go Renames/extends unit tests and adds cases covering self-chat detection and except fallback behavior.

rusq and others added 3 commits March 9, 2026 18:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@rusq rusq merged commit 6fecb40 into master Mar 9, 2026
7 checks passed
@rusq rusq deleted the export-source branch March 9, 2026 09:22
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

Successfully merging this pull request may close these issues.

2 participants