Enhance EditorSession state to include token in active and read-only states; update editor handler to use new Collabora URL
This commit is contained in:
@@ -52,9 +52,9 @@ class EditorSessionBloc extends Bloc<EditorSessionEvent, EditorSessionState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!session.readOnly) {
|
if (!session.readOnly) {
|
||||||
emit(EditorSessionActive(editUrl: session.editUrl));
|
emit(EditorSessionActive(editUrl: session.editUrl, token: session.token));
|
||||||
} else {
|
} else {
|
||||||
emit(EditorSessionReadOnly(viewUrl: session.editUrl));
|
emit(EditorSessionReadOnly(viewUrl: session.editUrl, token: session.token));
|
||||||
}
|
}
|
||||||
_expiryTimer = Timer(
|
_expiryTimer = Timer(
|
||||||
session.expiresAt.difference(DateTime.now()),
|
session.expiresAt.difference(DateTime.now()),
|
||||||
|
|||||||
@@ -13,20 +13,22 @@ class EditorSessionStarting extends EditorSessionState {}
|
|||||||
|
|
||||||
class EditorSessionActive extends EditorSessionState {
|
class EditorSessionActive extends EditorSessionState {
|
||||||
final Uri editUrl;
|
final Uri editUrl;
|
||||||
|
final String token;
|
||||||
|
|
||||||
const EditorSessionActive({required this.editUrl});
|
const EditorSessionActive({required this.editUrl, required this.token});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [editUrl];
|
List<Object> get props => [editUrl, token];
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorSessionReadOnly extends EditorSessionState {
|
class EditorSessionReadOnly extends EditorSessionState {
|
||||||
final Uri viewUrl;
|
final Uri viewUrl;
|
||||||
|
final String token;
|
||||||
|
|
||||||
const EditorSessionReadOnly({required this.viewUrl});
|
const EditorSessionReadOnly({required this.viewUrl, required this.token});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [viewUrl];
|
List<Object> get props => [viewUrl, token];
|
||||||
}
|
}
|
||||||
|
|
||||||
class EditorSessionFailed extends EditorSessionState {
|
class EditorSessionFailed extends EditorSessionState {
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ func editorHandler(w http.ResponseWriter, r *http.Request, db *database.DB, audi
|
|||||||
|
|
||||||
// Build Collabora editor URL - Collabora needs the file download URL as the WOPISrc parameter
|
// Build Collabora editor URL - Collabora needs the file download URL as the WOPISrc parameter
|
||||||
editUrl := fmt.Sprintf("https://go.b0esche.cloud/orgs/%s/files/download?path=%s", orgID.String(), url.QueryEscape(file.Path))
|
editUrl := fmt.Sprintf("https://go.b0esche.cloud/orgs/%s/files/download?path=%s", orgID.String(), url.QueryEscape(file.Path))
|
||||||
collaboraUrl := fmt.Sprintf("https://collabora.b0esche.cloud/lool/dist/mobile/cool.html?WOPISrc=%s", url.QueryEscape(editUrl))
|
collaboraUrl := fmt.Sprintf("https://of.b0esche.cloud/lool/dist/mobile/cool.html?WOPISrc=%s", url.QueryEscape(editUrl))
|
||||||
|
|
||||||
// Check if user can edit (for now, all org members can edit)
|
// Check if user can edit (for now, all org members can edit)
|
||||||
readOnly := false
|
readOnly := false
|
||||||
|
|||||||
Reference in New Issue
Block a user