Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

How can SO tell which vote the user wants to delete?

The vote request URL usually follows this pattern:[postId]/vote/[voteTypeId]

If, for example, I accepted post 99 as an answer the request URL would be:

When I reverse a vote, however, I believe the voteTypeId is set to 0 in the request URL. So, using the example I gave, if I un-accepted post 99 as an answer to my question the following request URL would appear:

How can SO figure out that I want to un-accpet the answer as opposed to reverse another type of vote; like a favouite or an up vote, for example?

share|improve this question
If you're tracking the requests sent by the browser, why not try it and find out? I'm curious to hear the results. – Jon Seigel Jan 13 '11 at 18:07
Jon, I did this earlier but there were no params sent with the URL request other than the postId and the voteTypeId. I did some further investigation, however, and found some partial conclusions. See my answer. – Mohamad Jan 13 '11 at 18:49
FYI: to comment-notify users, precede their user name with an @. – Jon Seigel Jan 13 '11 at 23:46
up vote 1 down vote accepted

After further thought I found out the follwing:

When users accept answers or add favourite questions, the vote request URL is a toggle request. The voteTypeId found at the end of the URL remains consistent whether this is a do or an undo action.

Using the earlier example, if I were to accept post 99 as an answer and then un-accept it, the request URL would be the following for both actions:

This indicates a toggle request. This behaviour is also consistent when adding and deleting favourite questions.

Casting mod votes is different, however. When a user casts a mod vote the request URL is consistent with other vote types. Undoing a mod vote is handled differently; the URL request to undo a mod vote always ends with 0.

I imagine this is because mod votes are mutually exclusive; you can not have an up and a down vote on the same post. Therefore, the back-end will attempt to delete the mod vote regardless of its type.

There is a mystery 'LastvoteTypeId' included in the returning JSON when votes are cast. Its value is set to null when any vote is deleted. However, when a mod vote is cast, LastVoteTypeId returns as the voteTypeId of the respective vote. So 2 when the vote is a mod up, and 3 when the vote is a mod down.

I'm yet to ascertain what this does.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .