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.
 * on local wikis changed: earlier posts return a string, newer return an integer. As a result code confused about which posts were written by someone else and are thankable.
 * Security:
 * Sanitizing all inputs
 * Right now AbstractRevision::getContent is used to obtain topic title; method docs say we should use Templating::getContent which does permission checks--is this necessary?
 * The API should check whether a post ID is valid
 * Supporting users with JavaScript disabled
 * Right now the link links to a non-existent special page
 * Testing! JavaScript unit tests and browser tests
 * Remembering Thanked state (Thanks does it in PHP session and cookie)
 * Ensure the cookie and session functionality to remember Thanked state does the right thing
 * Validate assumptions (thanking original poster vs. editor, etc.)
 * Other refinements

Things spage noticed

 * I wound up with two  cookies, one for the path /wiki/index.php and one for /wXXXXpath  That might be a Thanks issue.
 * After I did a Flow thanks, I had a thanks-thanked cookie with no value.
 * In the Thanks.flow  hook,   isn't a Revision object, it's a FlowRevision.

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

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

Script (WIP)
Hi, my name is ___ from ___, with me I have ___ from ___ and the two of us are working on the Flow extension for MediaWiki.

(The other one will take over somewhere below, similar self-introduction)

Intro to Flow
Flow is a big initiative to improve discussion and collaboration on MediaWiki, the open source software that powers wiki websites such as Wikipedia. For years, on-wiki discussions were based on the same interface and toolset that were used for article editing - plaintext mixed with complex wikicode, without an efficient WYSIWYG interface. This presents a significant barrier to new users, or even some experienced users. Flow, however, is a complete redesign of the user interface for discussions on Wikipedia.

Currently, MediaWiki allows users to thank other users for their edits, and we have added a similar capability for comments on Flow boards. We hope that adding such functionality to Flow will make it easier to show appreciation for each other's contribution in discussions, and in particular, to encourage the new users to be more active in on-wiki discussions.

Since the beginning of the code sprint, we have implemented an initial version of the feature. Next we will be focusing on creating unit tests and browser tests, supporting users without JavaScript and refining the feature.

Demo
Here you have a comment on a Flow discussion board. If you find the comment helpful, you can thank the author using the "Thank" button. On clicking it, the button changes to say "Thanked" to show that a notification was successfully sent.

Now if you log in as the author, you can see that you have received a new notification. When you click the indicator, you see that someone else has thanked you for your comment. Clicking on the message takes you to the comment in question.

Implementation
To implement the feature, We added a "hook" to Flow so other extensions can add additional buttons for a Flow comment. We then implemented a hook handler that appends a "Thank" button to every comment. Through JavaScript, the button triggers an in-page call to an API, which generates a "thank you" notification for the author of the comment. The existing notification system is used to deliver the notification to the recipient.


 * some personal thoughts about the code sprint/FBOA in general to end things off?