Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

#8696 closed defect (bug) (fixed)

BP REST API Messages endpoint does not return latest message in excerpt field

Reported by: niftythree Owned by: espellcaste
Priority: normal Milestone: 12.0.0
Component: REST API Version:
Severity: normal Keywords: dev-reviewed has-patch has-unit-tests
Cc:

Description

Hello again,

As you may know from our previous thread, we’re working on the messaging portion of our mobile app which interfaces to the BP REST API. We’ve noticed that the “messages” endpoint in the API returns an “excerpt” which is quite handy. However, it’s not necessarily the excerpt of the most recent message, instead it's an excerpt of the last message in the current batch returned by the API. To get the actual latest message it is necessary to call the messages endpoint repeatedly until it has reached the end of each of the message threads, which is not very efficient from the app’s end and slows things down quite a bit. Would it be possible to change this so that the excerpt returned is of the latest message? (i.e. when retrieving the Inbox, the excerpt would be the last incoming message, when retrieving the Sentbox the excerpt would be from the last outgoing message).

Thank you.

Attachments (1)

Latest Message.png (17.2 KB ) - added by niftythree 4 years ago.

Download all attachments as: .zip

Change History (11)

#1 @espellcaste
4 years ago

  • Keywords needs-patch dev-reviewed added
  • Milestone Awaiting ReviewUp Next
  • Owner set to espellcaste
  • Status newassigned
  • Type enhancementdefect (bug)

@niftythree Good catch! This is actually a bug in the implementation. Since we are getting paginated batch of messages, we are actually losing the last one which is the lastest message.

I'll work on a fix.

Last edited 4 years ago by espellcaste (previous) (diff)

This ticket was mentioned in Slack in #buddypress by espellcaste. View the logs.


4 years ago

#3 @niftythree
4 years ago

Hi @espellcaste,

Thanks for looking into this. We actually thought this was how it was originally intended to work. 🙂

#4 @espellcaste
4 years ago

  • Milestone Up Next11.0.0

#5 @espellcaste
4 years ago

  • Milestone 11.0.0Up Next

This ticket was mentioned in PR #52 on buddypress/buddypress by renatonascalves.


4 years ago
#6

  • Keywords has-patch has-unit-tests added; needs-patch removed

renatonascalves commented on PR #52:


4 years ago
#7

@imath Could you take another look? I improved the implementation to handle the cache in a better way.

This ticket was mentioned in Slack in #buddypress by espellcaste. View the logs.


4 years ago

#9 @imath
4 years ago

  • Milestone Up Next12.0.0

#10 @espellcaste
4 years ago

  • Resolutionfixed
  • Status assignedclosed

In 13402:

BP_Messages_Thread: return the *right* latest message.

Introducing a new method get_latest_thread_message() to the BP_Messages_Thread class which returns the latest message of a thread.

Closes https://github.com/buddypress/buddypress/pull/52
Fixes #8696

Note: See TracTickets for help on using tickets.