mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.25k stars 1.36k forks source link

Direct messages with unknown users (no username) in App v2 #7105

Open david-strejc opened 1 year ago

david-strejc commented 1 year ago

In screenshot there is an issue where we got Direct Messages with users whom been deleted via mmct long time ago - but somehow only in Mobile App v2 there are still persistent Direct Messages channels.

If there is a way (SQL command) how to permanently delete such channels (as they are not needed anymore) we appreciate it.

image

amyblais commented 1 year ago

@david-strejc What OS and version are you on? What Mattermost server version are you on?

david-strejc commented 1 year ago

@amyblais Mobile app version 2.0.1 on Android. Server version: Mattermost Version: 7.7.1 Database Schema Version: 100 Database: mysql

larkox commented 1 year ago

@david-strejc I don't know of any particular tool on mmctl that would do that (nevertheless, I asked in the community server, in case anyone more involved is aware).

Nevertheless, there are a few tables at work here, so it is going to be a bit troublesome...

First of all you would have to find all the orphaned channel memberships (channel may exist, but the user doesn't). This may have been already done, so makes things a bit more complicated. If the memberships are there, then, check all the channels those people belong to, and remove all of those that are DMs. If the memberships don't exist, check all DMs to check if at least one of the members (using the channel name, if I remember correctly) is no longer available and delete them. With that, you should stop seeing this, but you still would have lots of "orphaned" data in the database.

Among other things, you should remove from the categories tables all references to the deleted channels. You may also want to remove posts and threads from the deleted channels, since you are no longer using them.

Once all that is removed (and I may be missing some table), the local state of the mobile app may still be in a weird state, so I would recommend log out and log back in, so the local state gets reset.

As you can see, this is not easy at all, and have a lot of things that can go wrong, so I would try this on a test environment before trying it on production.

Just to be sure, how did you remove the users? I want to make sure that if we have any tool to remove the users, the tool takes this into account.

david-strejc commented 1 year ago

@larkox there is strange thing which is this is not happening in web interface and in old app v2 everything was ok - but it is on our side so we will investigate this further

larkox commented 1 year ago

@david-strejc We will probably make the client "smarter" in the sense that will filter those out (the same as V1 and web), but even in that scenario, probably you don't want to have dangling orphaned data in your database, so let us know if we can help figuring out what dangling data is left :smile:

ChristianCiach commented 1 year ago

I have the exact same issue on android, starting with version 2.0.0 and still there with 2.1.0.

I have the suspicion that this is caused by an inconsistent state of the server database. For privacy and security reasons our admins regularly purge all old messages by directly deleting those from the servers database (or so I've been told). Maybe this leads to some orphaned references left in other tables. I not one of our admins, so I've no way to confirm this theory.