Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the Activity Type API and replace favorites with likes! #238

Closed
wants to merge 12 commits into from

Conversation

imath
Copy link
Member

@imath imath commented Feb 26, 2024

I'm back again with Favorites improvement. The story of this ticket highlighted the fact we should consider moving to Likes. I agree and now we have a Backward Compatibility Add-on (BP Classic). I believe we should move the Activity Favorites feature into this Add-on and finally have Likes instead into BuddyPress.

I've tested many ways to fix this ticket and I believe I finally have something solid to improve how we deal with Likes or more globally with Reactions to an activity. My reasoning to build the Activity Likes feature is Activity comments or Activity Likes are both reactions to an activity: I like what the activity says or I reply to it. So Activity Likes can be compared to Activity comments without content. If this PR is still a WIP, it already contains:

  • An Activity Type API (it should help us fix #6429
  • Examples of what improvements this API can bring: see the bp_activity_type_supports() function.
  • An initial Reaction API I'm inaugurating with the Activity Likes feature.
  • Adding/Removing Likes, getting likes count for an activity, getting the activity the user liked

Next steps if we agree on this scenario:

  • List the users who liked an activity on the Activity single screen
  • Ajax/JavaScript implementation into Template packs

More possible ambitious steps:

  • Sort Activity stream according to number of activity likes
  • Sort Activity stream according to number of comments.

I really think we should go this road for Activity Reactions/Likes. What do you think? Should we make this the 14.0.0 release top feature?

Trac ticket: https://buddypress.trac.wordpress.org/ticket/5644


This Pull Request is for code review only. Please keep all other discussion in the BuddyPress Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the WordPress Core Handbook for more details.

@emaralive
Copy link

Maybe if I explain it this way, you may gain a different perspective. Currently, I am a member of a site that has ability to Like activity posts in addition to being able to Favorite activity posts. As a matter of fact, the site admin has relabeled Favorites to read as Bookmark which allows members to have a list of activity posts that they can just refer to because:

  • They can Like the post at a later time/date.
  • They can Comment on the post at a later time/date.
  • They can later refer to the post for sharing purposes at a later time/date.

Seems to me, you are creating an either this or either that situation by moving the Favorites functionality into BP Classic. I'm not sure why site admins can't have both as is currently possible now.

Copy link
Member

@renatonascalves renatonascalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @emaralive

Let's leave to the community owner to decide how they wanna use each feature. See Instagram for an example of a community where people can like an activity, but you can also bookmark/favorite a post/activity. Each serves different purposes.

I also think this is being attached to the Activity component, but a plugin developer could very well build a feature to like groups, messages, users, or posts. The BuddyPress Followers plugin has a nice API that allows for extension for different scenarios. Something we could use as an inspiration here.

I left a few notes to the code. :)

src/bp-activity/actions/dislike.php Show resolved Hide resolved
src/bp-activity/actions/dislike.php Outdated Show resolved Hide resolved
src/bp-activity/actions/dislike.php Outdated Show resolved Hide resolved
src/bp-activity/bp-activity-filters.php Outdated Show resolved Hide resolved
src/bp-activity/bp-activity-functions.php Outdated Show resolved Hide resolved
src/bp-activity/bp-activity-functions.php Show resolved Hide resolved
src/bp-activity/bp-activity-template.php Show resolved Hide resolved
src/bp-activity/bp-activity-template.php Outdated Show resolved Hide resolved
src/bp-activity/classes/class-bp-activity-component.php Outdated Show resolved Hide resolved
@imath
Copy link
Member Author

imath commented Feb 27, 2024

@emaralive & @renatonascalves

Thanks a lot for your feedbacks, I'm just following the consensus that was found about choosing both features, favorites or likes only:
See https://buddypress.trac.wordpress.org/ticket/5644#comment:36

Moreover, Favorites are very buggy, we really should deprecate it. If there's a strong willing to absolutely keep the idea of Bookmarking I'll surrender but in this case it should be rebuilt as the Like feature using an activity type having a reaction role.

@renatonascalves
Copy link
Member

@imath I don't have a strong opinion about it. To be honest, I'm not sure if this feature is used a lot in communities.

If we can deprecate it without any major issues to users, great. I do have a strong opinion that the API should be flexible enough that plugin developers can use it for other components, if desired.

BuddyPress is very good at being extendable to developers. The current API in this pr could do with some improvements, getting the reactions is a bit burdensome, lots of PHP filtering.

@imath
Copy link
Member Author

imath commented Feb 28, 2024

@renatonascalves thanks for your review by the way, I'll update the PR accordingly. This is still a WIP but I believe the Activity Type API combined with the reaction one will improve & simplify things.

@emaralive
Copy link

@emaralive & @renatonascalves

Thanks a lot for your feedbacks, I'm just following the consensus that was found about choosing both features, favorites or likes only: See https://buddypress.trac.wordpress.org/ticket/5644#comment:36

@imath & @renatonascalves

Seems to me the referenced comment was from 9 years ago, of which, that was the thought then (2015) and this is now (2024). AFAIK, things/thoughts/conditions change over time.

Moreover, Favorites are very buggy, we really should deprecate it. If there's a strong willing to absolutely keep the idea of Bookmarking I'll surrender but in this case it should be rebuilt as the Like feature using an activity type having a reaction role.

As to buggy, could you expand upon this notion, @imath? The last bug I remember is reconciling Activity IDs after an Activity/Comment was deleted.

I'm trying to imagine how Slack would work without the ability to Save for later (bookmark); meaning, I can only react to a message. I suppose I could manually copy the message link and save it in a text file but, that would actually be archaic and I shudder at the thought.

However, in all fairness, I've not checked out this PR to see how it actually works and when I get an opportunity, I will do so. If, by chance, there isn't the ability to bookmark then I would recommend the exploration of "it should be rebuilt as the Like feature using an activity type having a reaction role" because I don''t know what that means nor what it would look like.

@dcavins
Copy link
Contributor

dcavins commented Feb 28, 2024

I agree that bookmarking/favoriting and liking posts are two different types of actions, and while adding reactions is a great improvement (and probably expected funtionality for most users), I'd hate to lose bookmarks, for those users who are bookmarkers. If bookmarks are buggy, we should fix them. I'm guessing that one of the issues is that the old code stored them in a serialized array (I'm guessing about this), so when an item is deleted, it's hard to remove them from all of the serialized arrays.

Reactions are great!

@imath
Copy link
Member Author

imath commented Feb 28, 2024

Ahaha thanks a lot 😍 for your reactions 😉 @dcavins & @emaralive.

As David explained using serialized information into a user meta will always be a trouble and we need to avoid doing this as much as we can (we sometimes have no other choices).

Favorites are already gone, reading your 2 comments: you're now talking about bookmarks so I think we can satisfy everyone's expectations:

  1. the current "Favorites" is "classic" BuddyPress and needs to be deprecated, moved to BP Classic so that very conservative users can always enjoy it.
  2. Modern BuddyPress is "Likes" & "Bookmarks".

Likes: will help make the most interesting activities to rise once we'll be able to sort activities according to the number of likes or comments. So that's the most interesting feature to me, it's a community feature in the sense that thanks to the public expression of the community members I can see the best of activities.

Bookmarks are a "selfish" need, it's less interesting to me, but, I was actually using it on Twitter 😁 (I'm not saying the before last letter of the Alphabet, because I left Twitter before it was renamed). So "technically" speaking: to me, "Bookmarks" are hidden "likes" only visible to me. I can go to my list of bookmarks, read the activity, then remove the bookmark once I've read it. I agree it's interesting to build this feature using reactions and probably use this feature to eventually migrate the favorited activities that are still existing.

But Favorites are different, it's more persistent. My favorite movie is Matrix, my favorite pizza is Pepperoni : it won't change... I think BP Favorites were used as bookmarks.

In short can we agree on, let's build 2 Activity reactions in 14.0.0:

  • Likes
  • Bookmarks

and keep Favorites, but, into the BP Classic Add-on 🧐 ?

@renatonascalves
Copy link
Member

Technically speaking, will I be able to add Group reactions? Like a group? Bookmark a group? A blog post? Like a message? Bookmark a message (similar to Slack)?

Let's not build the API attached to the Activity component since that's not the only one a site might need it. So naming Activity reactions might be the wrong start. Having a "Reactions API" might be better.

@imath
Copy link
Member Author

imath commented Feb 28, 2024

💥

Thanks @renatonascalves for your feedback. I understand you expect something larger than Activity "Reactions". Maybe the "Reaction" word is a problem, btw. To me a comment is already an activity reaction, for example.

  1. I'm afraid what you seem to suggest won't be achieved in 4 months for 14.0.0. A centralized Reaction API makes me think about this project that never happened: https://github.com/buddypress/bp-relationships
  2. Thanks for insisting about https://github.com/r-a-y/buddypress-followers I wasn't aware it included features to subscribe/follow an activity or a blog. I thought it was only targeting users.
  3. FWIW: about liking, bookmarking a group, a post, a blog : you'd be able to do so liking or bookmarking the activity generated by these objects. To me liking a group or a blog does less sense than an activity, a comment or a post by the way.
  4. Messages: the star feature is doing a nice job, I believe.

I'm not as ambitious as you seem to be. I'm suggesting to satisfy a need I often read on BuddyPress support or in reviews about it, find a way to:

  • introduce Activity likes (as a replacement of favorites was my understanding of the ticket's history).
  • I thought it could replace gracefully Favorites, but understood the majority of the team thinks we should keep this feature
  • introducing Activity bookmarks using some kind of hidden likes can be done for 14.0.0 and I hope can satisfy @emaralive & @dcavins concerns.

But this ticket is not about building a central Reaction API (I'll edit the PR's title as I admit it was misleading), it's about improving favorites management. I'm now trying another alternative way using activity children to create likes or bookmarks just like we do for comments.

So:

  • If the "Reaction" word is a problem, I'm fine with using another one 😃.
  • If using activity children to manage likes or bookmarks is a problem or everyone thinks a central reaction API is the right way to fix this ticket, I can halt there and move to another ticket.

I begin to believe this ticket is cursed 😂 🧙‍♀️ At least, I've tried many ways to improve the current Favorites situation for 10 years!

@imath imath changed the title Introduce the Activity Type API, the Reaction API and replace favorites with likes! Introduce the Activity Type API and replace favorites with likes! Feb 28, 2024
@renatonascalves
Copy link
Member

Agree! Let's move the convo for an extendable API for https://github.com/buddypress/bp-relationships or a related ticket. I mistakenly assumed that was the goal here.

Thanks for insisting about https://github.com/r-a-y/buddypress-followers I wasn't aware it included features to subscribe/follow an activity or a blog. I thought it was only targeting users.

I used it before to add a feature to a client site. It has a good database schema that made the job a breeze.

imath and others added 11 commits March 10, 2024 13:43
This will be needed to use likes as activities having the 'reaction' role.
Improve the Activity Type API to include a callback to set the primary link.
Introduce the `BP_Activity_Activity::append_reactions()` as well as the `BP_Activity_Activity::get_activity_reactions()` methods to get Likes for activities.
This commit also tries to avoid querying for the same parent multiple time when adding a like.
Introduce the `bp_activity_get_user_reactions()` to fetch the activity IDs a user liked.
@imath
Copy link
Member Author

imath commented Mar 10, 2024

I just refreshed the PR, but I won't work on improving the Activity Favorites / Likes (or eventually Activity Bookmarks) feature anymore (although "Likes" is one of the features users expect to finally get in BuddyPress just like it was the case for the private visibility).

I understood you all disagree with my strong conviction that it has to be managed using Activity children just like Activity Comments.

Let's wait for an hypothetical more global BP Reactions API to land one of these days in BuddyPress (eg: https://github.com/buddypress/bp-relationships)... The ironical part about it would probably be that users will want these reactions to generate activity entries (duplicate info we could have avoided with the way I'm convinced we should use). Nevermind.

Instead I'll pick the part about the Activity Type "API" to clean the mess currently existing between Activity Actions & Activity Types from this ticket #6429.

@imath imath closed this Mar 10, 2024
@imath imath deleted the try/activity-types branch March 10, 2024 14:14
@renatonascalves
Copy link
Member

Just adding my two cents here that, I know you are unhappy with this outcome, and I totally understand the frustration.

However, long term, I do think having a relationship API is the right approach to take, even if it takes longer to get there. I'm personally invested in this feature, so you can be sure we will make some progres in the next release.

The ironical part about it would probably be that users will want these reactions to generate activity entries (duplicate info we could have avoided with the way I'm convinced we should use).

^ here I think we will need to have better integration not only with the activity component, but also with the notifications component, the settings component (so that one can turn off notifications), etc.

There is another ticket related to the notifications part somewhere. But the pieces are all connected. Your work on the Activity Type "API" will help with this task too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants