Can I get findFilteredTopics to get Pms?

AI-generated summary

pfaffman is exploring how to display private messages (PMs) on pages like /unread using findFilteredTopics. They initially tried filtering by query parameters but realized PMs aren’t handled like regular topics. pfaffman discovered that PMs can be accessed using a specific filter format, such as topics/private-messages-group/username/groupName, as seen in the Discourse source code pfaffman. This approach allows retrieving PMs for specific groups, though the exact method for filtering unread or new messages remains unclear.

I’m interested in doing something like GitHub - nolosb/discourse-featured-lists: A Discourse theme component to feature custom topic lists. · GitHub that makes Pms display on some other pages (like latest).

The idea is that group PMs can be hard to find, so if I could get, say, unread group pms to display on /unread then that would be really cool.

Pretending for a minute that I can figure out how to get them to display, what I need is to get the data so that I can display it.

Can I do something like this:

    const topicList = await this.store.findFiltered('topicList', {
      filter: this.args.list.filter,
      params: {
        category: this.args.list.category,
        tags: this.args.list.tag,
        solved: solvedFilter,
      },
    });

but make the params get, say, the group PMs for staff or team or whatever?

Well, it looks like I can sort-of do it like this:

    const topicList = await this.store.findFiltered('topicList', {
      filter: this.args.list.filter,
      // filter: "search",
      params: {
        // category: this.args.list.category,
        // tags: this.args.list.tag,
        // solved: solvedFilter,
        q: "upgraded in:messages"
      },
    });

that will give me my messages that have “upgraded” in them.

But I still can’t figure out how to get, say, unread messages, new messages, all messages, messages sent to a group.

Sigh. But it’s not a topic_list.

But wait!!! I found the right filter over in

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/routes/build-private-messages-group-route.js#L33

    let topicListFilter = `topics/private-messages-group/${this.currentUser.username}/${groupName}`;
    console.log("consider the topic list", topicListFilter);
    const topicList = await this.store.findFiltered('topicList', {
      filter: topicListFilter,
      params: { },
    });