I have a user case where I want a specific group of Users to automatically LIKE specific posts based on some criteria in a trigger.
Failed thoughts on how to accomplish this:
- Use DML. I experimented with FeedLike but it doesn't seem to support SOQL queries such as FeedItemn so DML operations to add these and set the CreatedById (or InsertedById) don't seem to be in the cards (or maybe it supports Insert operations and I quite experimenting too early.
- Use the ConnectApi sych as: ConnectApi.ChatterLike chatterLike = ConnectApi.ChatterFeeds.likeFeedElement(null, '0D5D0000000KuGh');
The problem with this is it runs as the current users context and I would need to look through this code (say for the three users) each time setting the user Context before running this command. This seems possible in Test mode but not in live mode using System.runAs()
- Making a call to the REST API with something like ForceTK: forcetk.Client.prototype.ajax(/feed-items/feeditemid/likes", callback, null, "POST", null);
The problem here seems to be related once again to the context. In this case I would need to use OAuth but don't plan to have the credentials stored etc... to validate automatically.
I get that this is probably a security feature to avoid abuse however it would be really handy for me to use this. I want to use Auto-Liking as a sort of way to subscribe people to immediate updates on specific Chatter posts. And other than auto Commenting on their behalf (which seems a bit more messy) I can't think of how to make it happen.
Any thoughts on how to accomplish this are much appreciated.