wa_strapi
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

34 rindas
902 B

  1. "use strict";
  2. /**
  3. * Read the documentation (https://strapi.io/documentation/developer-docs/latest/concepts/services.html#core-services)
  4. * to customize this service
  5. */
  6. module.exports = {
  7. // distinctbyKey: async (params) => {
  8. // const results = await strapi.query("message").find(params);
  9. // let arrKeys = [];
  10. // results.forEach((i) => {
  11. // if (!arrKeys.includes(i["session_datum_key"]))
  12. // arrKeys.push(i["session_datum_key"]);
  13. // });
  14. // return arrKeys;
  15. // },
  16. getQueueMessage: async (sessionId) => {
  17. var chat = await strapi.api["chats"].services["chats"].find({
  18. session_key: sessionId,
  19. });
  20. var arrayChat = chat.map((i) => i.id);
  21. var messageList = [];
  22. if (chat && chat.length != 0) {
  23. messageList = await strapi.api.message.services.message.find({
  24. _sort: "chat_key:desc",
  25. state: "QUEUE",
  26. chat_key_in: arrayChat,
  27. });
  28. }
  29. return messageList;
  30. },
  31. };