`baseVersionEtag` changes when a new document session got initialized,
e.g. after an old document session without session clients got cleaned
up, or because the markdown file got changed via webdav.
Detect this in the client and ask the user to reload the page for
resetting the session.
Signed-off-by: Jonas <jonas@freesources.org>
Instead of just deleting the newest steps, always remove all session
data: document, sessions and steps from the database as well as the yjs
(document state) file.
Without the `--force` option, don't reset document sessions with unsaved
steps.
Signed-off-by: Jonas <jonas@freesources.org>
When a text file is updated via other means than from the editor (e.g.
when uploaded/synced via webdav) and there is no unsaved steps in the
document session, reset the document session This will prevent conflict
resolution dialogs in this case. Client frontends will have to reload
the document afterwards though.
Signed-off-by: Jonas <jonas@freesources.org>
This fixes read-only clients getting 403 responses on push requests that
only contain questions for updates.
Fixes: #5223Fixes: #5366Fixes: #5368
Signed-off-by: Jonas <jonas@freesources.org>
Even if all sessions have expired and been removed
there may still be disconnected clients
that hold state from the last editing session.
When they reconnect they will send their yjs updates
based on the old state they had.
Preserve the yjs state accross editing sessions
so updates send after a reconnect can still be processed.
Signed-off-by: Max <max@nextcloud.com>
When viewer is available, not in use and supports the mimetype, and
we're not in a public share, open the attachment in viewer. Otherwise,
download the attachment.
Fixes: #3849Fixes: #4723Fixes: #5030
Signed-off-by: Jonas <jonas@freesources.org>
For all read-only attachments API endpoints, add support to authorize
with user session or share token when no document session is available.
Allows to get the attachments list and attachment files from
MarkdownContentEditor.vue without a document session.
Signed-off-by: Jonas <jonas@freesources.org>
If a user opens a public share link but does not have access to the file
in question on their filesystem, text failed to render the public share
link as we always tried to get the file directly.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
The value used before (largest possible MySQL BIGINT value) was too big
for PHP int. Since we still support 32-bit platforms on Nextcloud, let's
stick to the largest possible 32-bit PHP integer value.
Besides, setting the value as default for `Step::version` doesn't work
as `QBMapper->insert()` doesn't recognize the `version` field as changed
in that case. So let's default to `0` again and set it using
`Step->setVersion()` later.
Signed-off-by: Jonas <jonas@freesources.org>
Prevent a possible race condition when two clients add steps at the same time.
See #4600.
Rely on the autoincrementing id in order to provide a canonical order
that steps can be retrieved in.
When two clients push steps at the same time
the entries receive destinct ids that increment.
So if another client fetches steps in between
it will see the smaller id as the version of the fetched step
and fetch the other step later on.
Transition:
In the future we can drop the version column entirely
but currently there are still steps stored in the database
that make use of the old column.
So we need to transition away from that.
In order to find entries that are newer than version x
we select those that have both a version and an id larger than x.
Entries of the new format are newer than any entry of the old format.
So we set their version to the largest possible value.
This way they will always fulfill the version condition
and the condition on the id is more strict and therefore effective.
For the old format the version will be smaller than the id
as it's incremented per document while the id is unique accross documents.
Therefore the version condition is the more strict one and effective.
The only scenario where the version might be larger than the id
would be if there's very few documents in the database
and they have had a lot of steps stored in single database entries.
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Jonas <jonas@freesources.org>