Is there a way to see when an custom Emoji has been added & where and when the emoji was used?

Hi there,

I am looking to find out how to if there is a way to see when a custom emoji was uploaded and whether it has been used in any of the communication what time on what team and channel?

The front end does not give you this information aside from who it was uploaded by.

Thanks,
PecanPie

Hi PeacanPie and welcome to the Mattermost forums!

Sorry for the late reply, I just recently joined here.
You can get a list of all custom emojis + creationdate and creatorname by using the following query:

 select e.name,u.username AS creator,to_timestamp(e.createat/1000) AS created_at from emoji AS e,users AS u where e.creatorid != '' and e.deleteat = 0 and e.creatorid=u.id;

The output will look like this then:

                name                |    creator    |       created_at
------------------------------------+---------------+------------------------
 steel                              | agriesser     | 2020-12-18 10:54:37+01

To find out what emojis have been used in what posting, the query will be a bit more complex since you have to traverse through the posts table and run a string search there for all content.
A sample query would look like this:

select channelid,createat FROM posts where message like '%:emojiname:%';
         channelid          |   createat
----------------------------+---------------
 fraqzbpcoffjtradizmt54wgyc | 1652437014648
(1 row)

The problem here is, that you can only get the channelids back and would have to grab the names for the channels out of another table and for direct- and groupmessages, things will be a bit more clumsy.
Also you will probably need to also check on the reactions, because emojis can be used in reactions and they can also be used in custom statues, in badges, as icon urls for webhooks, etc. etc.

So not sure what you’re trying to achieve here, can you maybe explain the reasoning behind this request? Do you have offending emojis and want to use when people used them and in what context or do you want to get rid of stale emojis noone uses?

Don’t get me wrong, it’s defintely possible to create a script which produces such an output, but it will be some effort to create it.