Skip to content

Commit 9710cd7

Browse files
authored
Merge pull request #569 from talkjs/chore/add-data-directories
Add READMEs to empty directories in Sendbird migration example
2 parents 860e55c + 70e0a8a commit 9710cd7

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

rest-api/migrate-data-from-sendbird-to-talkjs/importers/channelImporter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const instance = axios.create({
1212

1313
async function importChannels(filePath) {
1414
try {
15+
// Check if file is JSON
16+
if (!filePath.toLowerCase().endsWith(".json")) {
17+
console.log(`Skipping non-JSON file: ${filePath}`);
18+
return;
19+
}
20+
1521
// Read and parse file
1622
const data = await fs.readFile(filePath, "utf8");
1723
console.log(`Read file: ${filePath}`);

rest-api/migrate-data-from-sendbird-to-talkjs/importers/messageImporter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ async function importBatch(conversationId, messages) {
7575

7676
async function importMessages(filePath) {
7777
try {
78+
// Check if file is JSON
79+
if (!filePath.toLowerCase().endsWith(".json")) {
80+
console.log(`Skipping non-JSON file: ${filePath}`);
81+
return;
82+
}
83+
7884
// Read and parse file
7985
const data = await fs.readFile(filePath, "utf8");
8086
console.log(`Read file: ${filePath}`);

rest-api/migrate-data-from-sendbird-to-talkjs/importers/userImporter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const instance = axios.create({
1212

1313
async function importUsers(filePath) {
1414
try {
15+
// Check if file is JSON
16+
if (!filePath.toLowerCase().endsWith(".json")) {
17+
console.log(`Skipping non-JSON file: ${filePath}`);
18+
return;
19+
}
20+
1521
// Read and parse file
1622
const data = await fs.readFile(filePath, "utf8");
1723
console.log(`Read file: ${filePath}`);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add your channel data files in this directory
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add your message data files in this directory
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add your user data files in this directory

0 commit comments

Comments
 (0)