Is there any way to get a user object by username or id via javascript?
It is difficult to answer without some more context. You can always do this: (try it in the dev tools for Meta)
Discourse.User.findByUsername("David_Taylor").then(function(user){
console.log("User Found", user);
});
But that will result in an additional request to the server, which may not be necessary.
What are you trying to achieve?
Thanks very much. I am trying to get a list of usersnames with certain custom field attributes. As you correctly pointed out, it will result in many additional calls from the API.
Is it possible to achieve what I intend more gracefully?
If this is just for administrators, you might be able to utilise the data-explorer plugin. If you wanted this to work for all users, you would probably need to create a plugin which adds a new HTTP endpoint.
イベントプラグインに関連するバグの1つに取り組んでいます。現在の実装はユーザー名に依存していました。これはエッジケースではありますが、ユーザー名は変更される可能性があるため、id でユーザーを取得できるようにする必要があります。
コアにも、id でユーザーを検索する同様のメソッドがあってもよいと思います。
ご意見をお聞かせください。
プラグインは、ユーザー名が変更された際にユーザー名参照を更新するか、必要なデータを取得するために必要なルートとシリアライザーを追加するかのいずれかができるようにする必要があります。
現在の状況でこれが可能か確認します。
はい。UsersController に ID でユーザーを検索するメソッドを追加し、Ember 側の User モデルにこの新しいコントローラーメソッドを呼び出すメソッドを追加する必要があります。