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

fix missing broadcast to all users #141

Merged
merged 3 commits into from
Oct 22, 2020
Merged

fix missing broadcast to all users #141

merged 3 commits into from
Oct 22, 2020

Conversation

pr4xx
Copy link
Contributor

@pr4xx pr4xx commented Oct 11, 2020

I think this sould resolve issues related to pads using regular as well as read only pad ids.
This commit basically updates each broadcast to include both ids. For that, the commentManager functions return both padIds in their callbacks.

padId = await readOnlyManager.getPadId(padId);
};
// We might need to change readOnly PadIds to Normal PadIds
var padIds = await readOnlyManager.getIds(padId);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed each occurence of readOnlyManager to use the getIds method. That way both ids are available independent of the given input id.

@JohnMcLear
Copy link
Member

Really good stuff, think it's worth putting some test coverage in just so I can be sure it doesn't get broken by someone else in the future? 👍

@JohnMcLear
Copy link
Member

Also, does read only before this PR = no comments or does it mean comments are visible but they don't update until refresh? If it's the latter that's fine.. If it's the former then we would need to add this under a setting. Having read only where comments aren't visible may be ideal to some.

@pr4xx
Copy link
Contributor Author

pr4xx commented Oct 12, 2020

for reference: #68 This comment

I am not really sure what happens prior to both my PRs.
My guess: at one point in time, etherpads core updated the readOnlyManager to use promises. That broke the translation in this plugin in commentManager whenever a read-only id was used.
My first PR solved that translation. But I noticed later that live syncing between non-read-only and read-only clients is not working. The problem was that the broadcast in index targeted the original id coming from the websocket. So all read-only clients could see their comments live. Same thing with all non-read-only clients. But not "between" those worlds.
My second (this) PR fixed this by sending each broadcast twice (to regular and read-only id).

When this PR gets merged, both "worlds" can see each other and even can edit each others comments. I am not sure if this is desired behaviour. Basically any "guest" (read-only) can edit and delete "admin" comments. I think #125 plays a role here.

So to fix this entirely I think we need to:

  • add configuration options for how comments should be handled between regular and read-only ids
  • fix authorization / add options for read-only permissions (guests can only read comments but not add own comments?)

I will add tests as soon as I find the time.

@JohnMcLear
Copy link
Member

FWIW I'm finding the ep_comments tests pretty damn unreliable. I'm trying to narrow it down and get them stable now.

@pr4xx pr4xx changed the title fix missing broadcast to all users WIP fix missing broadcast to all users Oct 12, 2020
@JohnMcLear
Copy link
Member

bumping @rhansen

@rhansen
Copy link
Member

rhansen commented Oct 12, 2020

Heads up: I just rebased your branch and force-pushed. git pull should do the right thing.

@rhansen
Copy link
Member

rhansen commented Oct 12, 2020

Looks good, thank you!

Would you mind updating the apiAddComments and apiAddCommentReplies events as well? Edit: I pushed a commit to your branch that updates them.

There are some pre-existing issues (not the fault of this PR) that should be addressed in separate PRs:

  • There's an awkward mix of async and callbacks. Edit: This is now fixed (server-side anyway).
  • There are a few significant security problems. (I don't want to go into details publicly until I've had a chance to patch them up.)
  • Not all hook functions call the callback like they should. Edit: This is now fixed.

@rhansen
Copy link
Member

rhansen commented Oct 13, 2020

I had a thought: Rather than call readOnlyManager.getIds(padId) deep in the code and propagate the IDs back up through the callbacks, perhaps the socket.io handlers should call readOnlyManager.getIds(padId) themselves and always pass the writable pad ID down. What do you think?

@rhansen
Copy link
Member

rhansen commented Oct 14, 2020

I pushed a commit to your branch that moves the readOnlyManager.getIds() calls to the socket.io handlers. It also updates the apiAddComments and apiAddCommentReplies handlers to match the others. If the end result looks good to you we can squash it into your commit.

@rhansen rhansen force-pushed the master branch 2 times, most recently from 86dae71 to ed5e163 Compare October 14, 2020 17:16
@rhansen
Copy link
Member

rhansen commented Oct 14, 2020

I was curious about how Etherpad core handles read-write vs. read-only users for normal edit messages, and it looks like it puts both types of users in the same socket.io "room". I think we should do that here for consistency. I'll push another commit.

@rhansen rhansen force-pushed the master branch 2 times, most recently from 199b9f6 to cac03f4 Compare October 14, 2020 23:39
@rhansen
Copy link
Member

rhansen commented Oct 14, 2020

I'll push another commit.

Done, and I rebased onto latest master. Let me know what you think @pr4xx.

pr4xx and others added 3 commits October 18, 2020 17:07
This reduces the complexity of commentManager. It also makes future
authorization checks easier to implement (because the checks should be
performed where the messages arrive, not deep in the abstracted
internals).

Also: Update the `apiAddComments` and `apiAddCommentReplies` message
events to broadcast to both pad IDs.
@rhansen rhansen changed the title WIP fix missing broadcast to all users fix missing broadcast to all users Oct 22, 2020
@rhansen rhansen merged commit b6078ad into ether:master Oct 22, 2020
@rhansen
Copy link
Member

rhansen commented Oct 22, 2020

I went ahead and merged this. Thanks for the fix @pr4xx!

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