Skip to:
Content

BuddyPress.org

#8696 closed defect (bug) (fixed)

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

Reported by: niftythree's profile niftythree Owned by: espellcaste's profile espellcaste
Milestone: 12.0.0 Priority: normal
Severity: normal Version:
Component: REST API 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 22 months ago.

Download all attachments as: .zip

Change History (11)

#1 @espellcaste
22 months ago

  • Keywords needs-patch dev-reviewed added
  • Milestone changed from Awaiting Review to Up Next
  • Owner set to espellcaste
  • Status changed from new to assigned
  • Type changed from enhancement to defect (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 22 months ago by espellcaste (previous) (diff)

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


22 months ago

#3 @niftythree
21 months ago

Hi @espellcaste,

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

#4 @espellcaste
21 months ago

  • Milestone changed from Up Next to 11.0.0

#5 @espellcaste
16 months ago

  • Milestone changed from 11.0.0 to Up Next

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


14 months ago
#6

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

renatonascalves commented on PR #52:


14 months 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.


14 months ago

#9 @imath
14 months ago

  • Milestone changed from Up Next to 12.0.0

#10 @espellcaste
14 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

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.