Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

slack_import: Ask user email support in case of unexpected failure.

Aman Agrawal4368ada5e535
diff --git a/templates/zerver/slack_import.html b/templates/zerver/slack_import.html
index d006c9c18b2..0dc9cd3917e 100644
--- a/templates/zerver/slack_import.html
+++ b/templates/zerver/slack_import.html
@@ -23,6 +23,16 @@
<div id="slack-import-poll-status" class="not-editable-realm-field">
{{ _("Checking import status…") }}
</div>
+ <div id="slack-import-unexpected-failure" class="not-editable-realm-field hidden">
+ <p class="text-error">
+ {% trans %}
+ An unexpected error occurred during the import process. Please follow the instructions for the
+ <a href="https://zulip.com/help/import-from-slack#import-your-data-into-zulip">
+ Zulip Cloud (via support) import process
+ </a> to complete your import.
+ {% endtrans %}
+ </p>
+ </div>
</div>
{% else %}
<form method="post" class="form-inline" action="{{ url('import_realm_from_slack') }}">
diff --git a/web/src/portico/slack-import.ts b/web/src/portico/slack-import.ts
index e6cfda591d5..27c8327db64 100644
--- a/web/src/portico/slack-import.ts
+++ b/web/src/portico/slack-import.ts
@@ -100,7 +100,16 @@ $(() => {
const {status, redirect} = z
.object({status: z.string(), redirect: z.optional(z.string())})
.parse(response);
- $("#slack-import-poll-status").text(status);
+ if (status === "unexpected_import_failure") {
+ $("#slack-import-poll-status").hide();
+ $("#slack-import-unexpected-failure").removeClass("hidden");
+ // Stop polling
+ if (poll_id) {
+ clearInterval(poll_id);
+ }
+ } else {
+ $("#slack-import-poll-status").text(status);
+ }
if (poll_id && redirect !== undefined) {
clearInterval(poll_id);
window.location.assign(redirect);
diff --git a/web/styles/portico/portico_signin.css b/web/styles/portico/portico_signin.css
index d9ac67feeda..4b525a474b0 100644
--- a/web/styles/portico/portico_signin.css
+++ b/web/styles/portico/portico_signin.css
@@ -1769,3 +1769,7 @@ button#register_auth_button_gitlab {
text-align: left;
}
}
+
+#slack-import-unexpected-failure .text-error {
+ font-size: 1em;
+}
diff --git a/zerver/views/registration.py b/zerver/views/registration.py
index aa18ae2d2cb..fe2afa4ae2d 100644
--- a/zerver/views/registration.py
+++ b/zerver/views/registration.py
@@ -350,7 +350,9 @@ def registration_helper(
return HttpResponseRedirect(
reverse("realm_import_post_process", kwargs={"confirmation_key": key})
)
- if prereg_realm.data_import_metadata.get("is_import_work_queued"):
+ if prereg_realm.data_import_metadata.get(
+ "is_import_work_queued"
+ ) or prereg_realm.data_import_metadata.get("unexpected_import_failure"):
return TemplateResponse(
request,
"zerver/slack_import.html",
@@ -1123,7 +1125,20 @@ def realm_import_status(
),
}
return json_success(request, result)
- # TODO: If there is something we need to fix for the import, we should notify the user.
+ else:
+ # The import failed due to an unexpected reason. Ask user to email
+ # support with the import file so that we can do the import manually
+ # and investigate the failure.
+ # If there was an error during import, it would have already been logged by Sentry.
+ # We don't have access to the exception here.
+ preregistration_realm.data_import_metadata["unexpected_import_failure"] = True
+ preregistration_realm.save(update_fields=["data_import_metadata"])
+ return json_success(
+ request,
+ {
+ "status": "unexpected_import_failure",
+ },
+ )
if realm.deactivated:
# These "if" cases are in the inverse order than they're done