I want to encourage my users to upload an avatar via api.
How can I know a user is using default avatar in discourse? because I don’t want to warn users that already have gravatars or their custom avatars set.
AI 生成的摘要
The discussion revolves around determining if a user is using a default avatar in Discourse. hnaseri wants to encourage users to upload an avatar and needs to identify those using default avatars. Their initial solution is to check for gravatar_avatar_upload_id and custom_avatar_upload_id in the /users/{username}.json endpoint, which vinothkannans confirms as a viable approach.
However, zogstrip points out that a Just-In-Time (JIT) message is already shown to users with default avatars. The challenge is that this message is associated with the composer and hnaseri is unsure if it can be retrieved via an API call.
zogstrip confirms that the message can be obtained via the API, and later reveals the endpoint as /composer_messages.json zogstrip. To utilize this endpoint, hnaseri is directed to the ComposerMessagesController source code zogstrip.
Alternatively, sam suggests using the Data Explorer with the query SELECT id user_id from users WHERE uploaded_avatar_id IS NULL to identify users without uploaded avatars.
I don’t know if its a good solution, but my solution for now is to look for gravatar_avatar_upload_id and custom_avatar_upload_id in /users/{username}.json and to see if they are both set to null.
Any idea?
I think it is the correct solution for you. For my knowledge only three types of avatars are there in Discourse (letter, gravatar and custom avatars). So it must work.
Out of curiosity: do you know we already show a JIT message to users with default avatar?
Yes I know. But I have implemented discourse in my application and users mostly post there. So i don’t know If this JIT message could be get with an api call. If it could be, I can call it when users perform some actions inside the application. But if it couldn’t be called with api call, I need to write a custom code for it.
These education messages are associated with the composer. I don’t know the exact endpoint, but I’m pretty sure you can get them via the API since it’s working in Discourse ![]()
So how should I reverse engineer it? Any idea? I need to make an account without avatar and wait for this message to appear? This is somehow awkward.
The endpoint is /composer_messages.json ![]()
Thank you very much. But how I can actually use it? ![]()
For example when user write their first topic in my app, I want to call this JIT and show the message.
You might want to look at the ComposerMessagesControllers’ source code ![]()
To figure out the list you can use data explorer:
SELECT id user_id from users
WHERE uploaded_avatar_id IS NULL