mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
FEATURE: Export chat messages to CSV file (#22113)
To export chat messages, go to `/admin/plugins/chat` and click the Create export button in the _Export chat messages_ section. You'll receive a direct message when the export is finished. Currently, this exports all messages from the last 6 months, but not more than 10000 messages. This exports all chat messages, including messages from private channels and users' direct conversations. This also exports messages that were deleted.
This commit is contained in:

committed by
GitHub

parent
720c0c6e4d
commit
3ea31f443c
@ -0,0 +1,10 @@
|
||||
<section class="admin-section">
|
||||
<h3>{{i18n "chat.admin.export_messages.title"}}</h3>
|
||||
<p>{{i18n "chat.admin.export_messages.description"}}</p>
|
||||
<DButton
|
||||
@label="chat.admin.export_messages.create_export"
|
||||
@title="chat.admin.export_messages.create_export"
|
||||
@class="btn-primary"
|
||||
@action={{action this.exportMessages}}
|
||||
/>
|
||||
</section>
|
@ -0,0 +1,22 @@
|
||||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default class ExportMessages extends Component {
|
||||
@service chatAdminApi;
|
||||
@service dialog;
|
||||
|
||||
@action
|
||||
async exportMessages() {
|
||||
try {
|
||||
await this.chatAdminApi.exportMessages();
|
||||
this.dialog.alert(
|
||||
I18n.t("chat.admin.export_messages.export_has_started")
|
||||
);
|
||||
} catch (error) {
|
||||
popupAjaxError(error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
import Service from "@ember/service";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default class ChatAdminApi extends Service {
|
||||
async exportMessages() {
|
||||
await this.#post(`/export/messages`);
|
||||
}
|
||||
|
||||
get #basePath() {
|
||||
return "/chat/admin";
|
||||
}
|
||||
|
||||
#post(endpoint, data = {}) {
|
||||
return ajax(`${this.#basePath}${endpoint}`, {
|
||||
type: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
<Chat::Admin::ExportMessages />
|
||||
|
||||
{{#if this.selectedWebhook}}
|
||||
<DButton
|
||||
@class="incoming-chat-webhooks-back"
|
||||
|
Reference in New Issue
Block a user