Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More features & breaking v2 changes #74

Merged
merged 18 commits into from
Jul 12, 2023
Merged

Conversation

dsevillamartin
Copy link
Member

@dsevillamartin dsevillamartin commented Jul 6, 2023

🔴 THIS PR IS NOT BACKWARDS COMPATIBLE. DO NOT TEST IN PRODUCTION. 🔴

This PR is intended to be merged after #73. Will need to change base to v2 & rebased.

Fixes #37
Fixes #38
Fixes #16

Changes proposed in this pull request:

  • Move voters button next to heading
  • Fix no permission error after poll ends
  • Create endpoint for new poll to add to existing post
    • Behavior & logic on post/discussion creation is the same - code is mostly shared
    • Prevent editing poll if user cannot edit post
    • Add policy to post for starting poll on said post - user must be able to edit post & start polls in discussion (tag scoped)
  • Drop 'newPollVote' websocket message
  • Remove deprecated single vote API endpoint
  • Drop ReFlar/polls database compatibility
  • Rename 'canSeeVotes' to 'canSeeVoters' in PollSerializer
  • Improve permissions
    • Added visibility scoping -- user must be able to see post
    • User must be able to edit post to edit poll

Reviewers should focus on:

Screenshot
image

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).

@@ -34,6 +34,7 @@
new Extend\Locales(__DIR__.'/resources/locale'),

(new Extend\Routes('api'))
->post('/fof/polls', 'fof.polls.create', Controllers\CreatePollController::class)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe be /posts/{id}/poll instead ? It makes more sense for how the post ID is provided to the backend. 🤷

dsevillamartin added a commit that referenced this pull request Jul 9, 2023
Adding/removing poll options still doesn't work, but that functionality is fixed in the follow-up PR #74
@Wlork
Copy link

Wlork commented Jul 10, 2023

Hello !

All the issues I reported on Flarum have been fixed. Congratulations ! 👍

Unfortunately, I detected more bugs.... But I can see the light at the end of the tunnel !

These are bugs linked to the "end date" option.

How can I explain it?

On a discussion or a post, you create the first poll with an end date. It works 👍

However, if you add another poll in the same post.... If you don't set an end date, it still creates a date automatically....
It's annoying, it shouldn't create a end date if you don't set anything.

It's a bug was hard for me to understand and reproduce, so I hope that I made clear :)

Also, It's not possible to remove the end date on any survey if you edit poll.

Thank

@dsevillamartin
Copy link
Member Author

However, if you add another poll in the same post.... If you don't set an end date, it still creates a date automatically....
It's annoying, it shouldn't create a end date if you don't set anything.

@Wlork Hm, I wasn't able to reproduce this... I created a poll with an end date, then on that same post, created another poll with no end date set. And it worked as intended - first poll has end date, second doesn't.

Also, It's not possible to remove the end date on any survey if you edit poll.

This is probably from my changes in #72. I need to check if v1 allowed you to remove an end date - there were already checks so that you couldn't make it sooner than it was set so I guess I assumed it didn't.

@Wlork
Copy link

Wlork commented Jul 10, 2023

@dsevillamartin

Hm, I wasn't able to reproduce this... I created a poll with an end date, then on that same post, created another poll with no end date set. And it worked as intended - first poll has end date, second doesn't.

I forgot to mention that you need to activate the multiple choice option.

Sorry about that !

This is probably from my changes in #72. I need to check if v1 allowed you to remove an end date - there were already checks so that you couldn't make it sooner than it was set so I guess I assumed it didn't.

I think it's good to be able to delete if needed :) Like the other options where we can enable/disable

@dsevillamartin
Copy link
Member Author

I forgot to mention that you need to activate the multiple choice option.

@Wlork I still can't reproduce this issue. Can you post a recording (gif or video upload works here on GitHub) showcasing the issue?

I think it's good to be able to delete if needed

I believe I have now reverted it back to the behavior in v1. Haven't built JS for it (too many commits with that 😅) but I'm not worried about that.

@Wlork
Copy link

Wlork commented Jul 11, 2023

@Wlork I still can't reproduce this issue. Can you post a recording (gif or video upload works here on GitHub) showcasing the issue?

Hello @dsevillamartin :)

I don't have this bug anymore. Or maybe I just can't reproduce it 😅

I believe I have now reverted it back to the behavior in v1. Haven't built JS for it (too many commits with that sweat_smile) but I'm not worried about that.

I'm not sure if I've understood you correctly, but I still can't cancel existing poll's end date :(

After the last update, I was able to run several tests.

I detected another bug.

As a member :

1- Create a discussion or a post with a poll
2- Reply to the discussion (or post), with or without a poll, it doesn't matter
3- Press F5
4- The edit and delete buttons for the previous poll have disappeared.
5- and so on

Apart from these two bugs, everything seems to be running smoothly on my side.

Once you've corrected these issues, I'll redo a complete test from A to Z :)

@dsevillamartin
Copy link
Member Author

dsevillamartin commented Jul 11, 2023

I'm not sure if I've understood you correctly, but I still can't cancel existing poll's end date :(

I didn't build the JS assets for it, so unless you do it in your vendor folder, it won't be fixed for you. I'm not worried about it still being a bug though.

2- Reply to the discussion (or post), with or without a poll, it doesn't matter

I've made it so that you need to be able to edit a post to edit and add polls. I feel like this makes sense, as polls are a part of the post. So this is intended behavior on my part. You have it set so you can no longer edit a post once it's been replied to, and that should (in my opinion) extend to its polls.

The butttons being gone is good - them not being gone beforehand is something that can't really be helped. The Flarum post "edit" button remains until refresh as well, even though the user no longer has the permission to edit that post.

What I'm wondering now is whether I took the "edit own polls" permission into consideration during this. I may add add a new permission for editing polls even if the user can no longer edit the post itself.

@Wlork
Copy link

Wlork commented Jul 11, 2023

I didn't build the JS assets for it, so unless you do it in your vendor folder, it won't be fixed for you. I'm not worried about it still being a bug though.

OK, I understand :)

I've made it so that you need to be able to edit a post to edit and add polls. I feel like this makes sense, as polls are a part of the post. So this is intended behavior on my part. You have it set so you can no longer edit a post once it's been replied to, and that should (in my opinion) extend to its polls.

The butttons being gone is good - them not being gone beforehand is something that can't really be helped. The Flarum post "edit" button remains until refresh as well, even though the user no longer has the permission to edit that post.

What I'm wondering now is whether I took the "edit own polls" permission into consideration during this. I may add add a new permission for editing polls even if the user can no longer edit the post itself.

I just checked and I didn't give permission to edit their posts in my forum test.... That's why I had this "issue". I changed it and it's fixed 👍

I'm sorry :(

Good.... We'll have to see how it works out in practice, but as far as I'm concerned, everything's OK :)
Would you like me to test anything in particular ? :)

@dsevillamartin
Copy link
Member Author

@Wlork I've split permissions for poll editing for more control (polls you create vs polls others create on your posts). And built the JS.

There's still some bugs and features that would be helpful, but I think this is good for an initial v2 release. If you're planning on re-testing everything, let me know & I'll wait. Otherwise I think I'm ready to merge & release #73 and this.

Thank you for all your testing again.

@Wlork
Copy link

Wlork commented Jul 12, 2023

Hello @dsevillamartin

I did all the tests from scratch :)

I can delete the end date when I edit a poll. The bug has disappeared 👍 The bug was probably due to the numerous updates....

Apart from that, I haven't found any major bugs :)

Just :

#74 (comment)

I saw this bug once. It appears when you add a poll on an existing post with at least one poll. But it's very random. I don't know when exactly this bug appears.... We'll have to see in practice with several users, I hope !

Thank you for all your testing again.

Thank you for taking the time to develop these features !

I'll say it again, it's a really good extension you've developed. If you need any further tests, don't hesitate to let me know 👍

dsevillamartin added a commit that referenced this pull request Jul 12, 2023
Adding/removing poll options still doesn't work, but that functionality is fixed in the follow-up PR #74
dsevillamartin added a commit that referenced this pull request Jul 12, 2023
* Move poll relation from one per discussion to many per post

* Rename permissions & add tag scoping to start, view results, and vote

* Change error message to explicitly state the user cannot start a poll

* Improve migrations - permissions delete on down, log deleted poll IDs

* Split discussion->post migrations to avoid half-ran state if migration fails within DB transaction

* Check all poll attributes in subtree check

Adding/removing poll options still doesn't work, but that functionality is fixed in the follow-up PR #74

* Always return 'voteCount' field in API response to properly update in frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants