mattermost / mattermost-plugin-apps

Powers the Mattermost App Framework
https://developers.mattermost.com/integrate/apps/
Apache License 2.0
34 stars 29 forks source link

post app button fail in multiuser (>=3) direct message channels #486

Closed sblaisot closed 5 months ago

sblaisot commented 5 months ago

With the following binding:

            {
                "location": "/post_menu",
                "bindings": [
                    {
                        "location": "make-a-thing-menu",
                        "icon": "thing.png",
                        "label": "Make a thing",
                        "description": "Use this post to make a thing.",
                        "submit": {
                            "path": "/make-a-thing-form",
                            "expand": {
                                "team": "summary",
                                "channel": "summary",
                                "post": "summary",
                                "acting_user": "summary",
                                "acting_user_access_token": "all",
                                "locale": "all",
                            },
                        },
                    },
                ],
            },

I have an app button on each post in the app post menu to "make a thing" with the post.

It works well for posts inside channels and for posts in private message between two users

As soon as it is a post in a direct message channel with more than two users, it fails.

clicking the app button in the app toolbar of a post in such a channel give me in the interface (and also in the logs) the following error message:

failed to expand context: failed post-expand consistency check: expanded channel's team ID  is different from user agent context 1ntjrqrqdjy8mffhoc44g1e9zr

Please note the two spaces between "team ID" and "is different" meaning that channel's team ID is "empty string"

This error messages comes from this mattermost code

How to add a post button for multiuser direct message channels?

sblaisot commented 5 months ago

This has to do with expand: channel: summary that don't work in a multiuser direct channel.

I think it's more a mattermost server bug than an app framework bug. I will report it there.

In the meantime I managed to workaround my bug by removing channel expand and making an api call to get channel details from post's channel_id (and this works for multiuser direct messages channels too)