Flow/Thanks

Upcoming feature, under development by Facebook Open Academy students. Trello card

Issues

 * Figure out if we can re-use Extension:Thanks
 * Thanks stores states in session and cookies for last 100 thanks made
 * Thanks link for edits appears on a history page, but according to trello, Flow has it besides the post itself.
 * Thanks depends on revId, Flow stores its own id.
 * No-Javascript

Approaches

 * Make Thanks aware of Flow
 * Reimplement Flow in Thanks
 * Subclass Thanks in Flow
 * getWithRoot
 * [16:54:21] to get the page its on you need the related workflow object, you can get that through the root post loader with $rootLoader->storage->get( 'Workflow', $res['root']->getPostId ); i think

What Thanks does

 * Register a new type of notifications with Echo
 * Eventually calls ApiThank::sendThanks, which creates an Echo event
 * Handles Echo's hooks to format and display notifications

Other (deferred)

 * remembering Thanked state (Thanks does it in PHP session and cookie)
 * The API should check whether a post ID is valid (and if possible, whether it matches the supplied workflow ID, titles and recipient) and reject invalid or inconsistent requests

Information needed for Flow Thanks API

 * PostRevision ID (post-id)
 * User ID of the original author (recipient; $origUserId in PostRevision)
 * Workflow ID (workflow)
 * Title of the topic (topic-title)
 * Page title (title)
 * Edit token (token; mw.user.tokens.values.editToken)
 * User object for the user sending Thanks ApiBase (through ContextSource) gives this to us for free

Sample API request from Thanks: ( new mw.Api ).get( {	'action' : 'thank',	'rev' : $thankLink.attr( 'data-revision-id' ),	'source' : source,	'token' : mw.user.tokens.values.editToken } )

Normal page Thanks implementation
Thanks responds to HistoryRevisionTools and PageHistoryBeforeList hooks,
 * responds in  by adding HTML

no-JavaScript: link to https://www.mediawiki.org/wiki/Special:Thanks/677745

JS: jQuery dialog, upon confirm make API call https://www.mediawiki.org/w/api.php?action=thank&format=json&rev=677745&source=diff&token=1aabf45aa2917fd61527b2941ad19304%2B%5C, response is success: 1, recipient: "username"

Recipient sees
 * Thanker thanked you for your edit on Page

Thanker links to person, the text links to https://www.mediawiki.org/w/index.php?title=Page&oldid=prev&diff=677745

Normal Echo notification of a Flow post
A Flow mention generates:
 * User mentioned you in their post Text of post on "Talk:Main Page".


 * User links to person
 * Entire notification links to https://www.mediawiki.org/w/index.php?title=Talk:Flow&workflow=050f35daa31600e9aae290b11c2788d8#flow-post-050f575cfa098b080b88782bcb087047
 * post links to the same thing