Mostrar lista de temas por array de IDs de temas

In our company we use discourse for everyday business.
Discourse is deeply integrated in our erp software.
For better organization of topics,our erp holds many kind of topics ids and posts ids.
In some parts of our app we want to show user list of specific topics in discource. (filtered by our citiera).
In our app there is form which users fills and our app has array of filtered topics.

Is there a way to send query string or formdata to discource endpoint among with array of wanted topics ids and to get list of topics in discource. (ideally with predefined order or ordered as array was)

Same needs we have for getting specific lists of posts by providing array of topics ids.

1 me gusta

También necesito esta funcionalidad. Ahora mismo lo estoy haciendo así, pero esto lleva demasiado tiempo.

    const selectedTopics = this.selectedTopics
     //consume los temas como IDs y devuelve los temas reales
     this.selectedTopicsID.forEach(function(tid,index){
       Topic.find(tid,{}).then(results => {
         selectedTopics.pushObject(results)
       })
     });

Estoy a punto de volver a abrir el listcontroller en mi plugin.rb y añadir un nuevo endpoint, y volver a abrir la topic-list en el inicializador del frontend para hacer algo similar a esto:

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/topic-list.js.es6#L129
Pero debe haber una forma más fácil de hacer esto. ¿Realmente no hay ningún endpoint para obtener temas en masa por ID?
Estaría muy agradecido por alguna ayuda :smiley:
EDITO: Así es como resolví este problema para mí:

Así es como se puede usar.

import TopicList from 'discourse/models/topic-list';
    const selectedTopics = this.selectedTopics
    //consume los temas como IDs
    TopicList.topics_array(this.selectedTopicsID).then(results => selectedTopics.pushObjects(results.topic_list.topics))

Ahora mismo esto todavía tiene la desventaja de que no devuelve objetos “reales” de Topic, pero supongo que añadir una línea como esta lo solucionará:

Aún no estoy seguro de si esta es la forma correcta de hacerlo y/o si esto rompe la seguridad.
Otra cosa que se podría hacer: primero buscar en la tienda si el registro ya está allí y luego cargar solo lo que no está, con fromMap. Similar a:

De todos modos, esto se está volviendo demasiado verbose aquí :smiley:
Esta es mi solución final, daré por terminado el día ahora:

2 Me gusta