ajones05 / seearound.me-ionic

0 stars 0 forks source link

Voting issue #117

Closed ajones05 closed 7 years ago

ajones05 commented 7 years ago

I've tried this several times, but it always seems to be the same: If I vote on a post (up or down), then leave and come back, then my vote is gone. I know we added the ability to see the vote right away, so that we don't need to check for server update on the vote count... not sure if that be responsible in some way?

abdulhafeez commented 7 years ago

It was a logical and scoping issue. Fixed.

abdulhafeez commented 7 years ago

Moreover, it can also happen if some old post doesn't have the canVote param as it was introduced quite late. So, all old posts should be deleted (or updated) before release.

ajones05 commented 7 years ago

This looks fine now, except a user is allowed to vote on his own posts again (this was changed, but it looks like it was changed back accidentally).

abdulhafeez commented 7 years ago

Looking at the code, it doesn't appear to be possible to vote your own post. The only possibility that comes to my mind is that the post may be very old where canVote param wasn't present.

The other possibility is that server side is not setting canVote properly.

abdulhafeez commented 7 years ago

@yuriyua I have produced this console output for you:

2016-10-17 23:55:31.057308 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.057496 SeeAroundMe[455:82450] Post ID: 4106 ------- canVote: 1 2016-10-17 23:55:31.057622 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.057739 SeeAroundMe[455:82450] Post ID: 4105 ------- canVote: 1 2016-10-17 23:55:31.057856 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.058074 SeeAroundMe[455:82450] Post ID: 4074 ------- canVote: 1 2016-10-17 23:55:31.058203 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.058322 SeeAroundMe[455:82450] Post ID: 3401 ------- canVote: 1 2016-10-17 23:55:31.058438 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 59 2016-10-17 23:55:31.058586 SeeAroundMe[455:82450] Post ID: 3707 ------- canVote: 1 2016-10-17 23:55:31.058823 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 59 2016-10-17 23:55:31.059018 SeeAroundMe[455:82450] Post ID: 3096 ------- canVote: 1 2016-10-17 23:55:31.059160 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.059274 SeeAroundMe[455:82450] Post ID: 3095 ------- canVote: 1 2016-10-17 23:55:31.059421 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.059541 SeeAroundMe[455:82450] Post ID: 3487 ------- canVote: 1 2016-10-17 23:55:31.059777 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.059898 SeeAroundMe[455:82450] Post ID: 2799 ------- canVote: 1 2016-10-17 23:55:31.060015 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 380 2016-10-17 23:55:31.060194 SeeAroundMe[455:82450] Post ID: 3114 ------- canVote: 1 2016-10-17 23:55:31.060316 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.060431 SeeAroundMe[455:82450] Post ID: 3485 ------- canVote: 1 2016-10-17 23:55:31.060548 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.060662 SeeAroundMe[455:82450] Post ID: 3471 ------- canVote: 1 2016-10-17 23:55:31.060777 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.060893 SeeAroundMe[455:82450] Post ID: 3708 ------- canVote: 1 2016-10-17 23:55:31.061008 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.061252 SeeAroundMe[455:82450] Post ID: 3332 ------- canVote: 1 2016-10-17 23:55:31.061377 SeeAroundMe[455:82450] User ID: 369 ---- Post User ID: 369 2016-10-17 23:55:31.061494 SeeAroundMe[455:82450] Post ID: 3486 ------- canVote: 1

You can see that canVote is always 1 regardless of user.

ajones05 commented 7 years ago

Looking at the code, it doesn't appear to be possible to vote your own post.

That's the way it should be. A user should not be able to vote on his own post. However, in the app it appears I'm able to vote on my own post (if I leave and come back, it is removed, but it should not record a vote for my own post to begin with).

abdulhafeez commented 7 years ago

canVote = 1 always is the reason. It was OK once, so it seems something changed on server side recently. @yuriyua should be able to see it.

yuriyua commented 7 years ago

Your account has admin privileges and you will always receive canVote=1 Admin can vote on any posts and can make unlimited votes

You can test it from another account, e.g. http://www.seearound.me/admin/mobile-api/request-nearest/token/2HXDD22TDCZ78GZT45CEQCZCD1MHADACX8QA9S6N66VDMV9R2M7R166E6TZG8AV5/latitude/1/longitude/1/submit

{
    "status": "SUCCESS",
    "message": "Nearest point data rendered successfully",
    "result": [
        {
            "id": "4075",
            "user_id": "379",
            "news": "www.google.com",
            "created_date": "3 weeks ago",
            "latitude": "1",
            "longitude": "1",
            "Address": "",
            "comment_count": "0",
            "vote": "0",
            "isLikedByUser": "0",
            "Name": "Test",
            "Profile_image": "http://www.seearound.me/uploads/default.jpg",
            "canEdit": 1,
            "canVote": 0
        },
...

The first post "canVote": 0

abdulhafeez commented 7 years ago

My code allows to vote only when canVote is 1. Now it is up to server, whom it allows and whom not.

yuriyua commented 7 years ago

OK. There still are problems?

abdulhafeez commented 7 years ago

I can vote on my own posts. But as you told I am admin, it may be OK. @ajones05 can tell what is required. I think no body including admins should be allowed to self vote.

ajones05 commented 7 years ago

@abdulhafeez on the web version admins can vote on all posts and can vote as many times as they want (this was to help me curate the posts while there are few people using it and voting). I think by trying to keep it as simple as possible, I caused the issue by not asking for the same on mobile. I am OK with whatever is easiest, but it should be one of these two for mobile:

  1. Only admins can vote on all posts (including their own), and as many times as they want (same as web)
  2. No one can vote on their own posts

Option 1 would be a little more preferable, but whatever is easiest is fine.

abdulhafeez commented 7 years ago

I have just confirmed by logging in with a different non-admin user, that I cannot self vote as non-admin user. So, it looks OK.

ajones05 commented 7 years ago

But either way there is still this issue (or has this been fixed now?):

If I vote on a post (up or down), then leave and come back, then my vote is gone.

abdulhafeez commented 7 years ago

This issue has been fixed.