Forum Discussion

peterlu's avatar
peterlu
Champion
11 years ago
Solved

API question - check if myself replied to a thread

Hi,

 

I have been researching this for a long time, and still cannot figure it out.

Is there a api to determine is myself(logged in) replied to a thread?

Cases:

1. If I create a topic, and there is no replies, this api should return false

2. If someone else creates a topic, and I reply to it, this api should return true

3. If I create a topic, and myself reply to it, this api should return true

 

Current workaround: I have to pull all messages out from a thread, and loop through them to find out if I did a reply. This works most of the time, but performance is bad. And if a thread has more than 100 messages, then very very bad.

 

I have also tried this API

http://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?leaf-id=User.participated.threads.id.thread_id#User.participated.threads.id.thread_id

 

But it is not working for my case #1.

 

Lithium has built-in components that get this working, eg. In the message list, the icon bubble image file name has "replied" in it. So I was wondering how Lithium is doing it. 

 

Peter

 


  • peterlu wrote:

    Anyone knows how to make this query in v2?


    Hey peterlu ,  I think you'll get what you need from

    SELECT * FROM messages WHERE author.id='1' AND parent.id = '123' LIMIT 1

    So if you get any data in that they've replied, if not it'll error out.

    Catch the error and do nothing or run the alternate code block.

     

    I've got big plans for what we can do with a thread if you've replied to it or not.  :D

6 Replies

  • peterlu's avatar
    peterlu
    Champion
    11 years ago
    VarunGrazitti we are not sure api v2 is there for version 14.10. And we don't know the v2 query string for this requirement. So yes, we have looked into v2. If you have a solution, that will be great. Thanks.
  • V2 is available for 14.10, you just need to get it enabled from Li support. Once you get it enabled, you can use LiQL to fetch the details as required. They are more powerful than the V1 in all the areas.
  • peterlu's avatar
    peterlu
    Champion
    11 years ago

    Anyone knows how to make this query in v2? I would like to know it is possible before I get my client to enable it.

     

    VarunGrazitti It would be more helpful if you had the solution :smileywink:

  • Tim_h's avatar
    Tim_h
    Boss
    11 years ago

    peterlu wrote:

    Anyone knows how to make this query in v2?


    Hey peterlu ,  I think you'll get what you need from

    SELECT * FROM messages WHERE author.id='1' AND parent.id = '123' LIMIT 1

    So if you get any data in that they've replied, if not it'll error out.

    Catch the error and do nothing or run the alternate code block.

     

    I've got big plans for what we can do with a thread if you've replied to it or not.  :D

  • peterlu's avatar
    peterlu
    Champion
    11 years ago

    Tim_h wrote: 

    I've got big plans for what we can do with a thread if you've replied to it or not.  :D


     

    Watch out. Tim_h found a gold mine.