Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use prisma migrate deploy instead of dev #1061

Merged
merged 42 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b1674f2
remove pending from BE and DS
AlexNi245 Jun 3, 2024
1d3a754
increase message count
AlexNi245 Jun 4, 2024
88c5f94
use prisma migrate deploy instead of dev
malteish Jun 26, 2024
3d7e8e7
fixed contact sticky issue
Bhupesh-mfsi Jul 5, 2024
5b3be6f
fix environment selection
malteish Jul 8, 2024
aba50fc
Merge pull request #1082 from dm3-org/fix_staging_deployment
malteish Jul 8, 2024
2aeaa08
Merge pull request #1081 from dm3-org/fix-overflow-issue
malteish Jul 9, 2024
72772ed
enable manual deployment to testing
malteish Jul 9, 2024
71e3d15
Merge pull request #1085 from dm3-org/manuallyDeploy
malteish Jul 9, 2024
9ef5607
fixed ens avatar url for IPFS
Bhupesh-mfsi Jul 10, 2024
75437c8
added image load check for avatar's
Bhupesh-mfsi Jul 10, 2024
e43f4e9
Merge branch 'develop' of https://github.com/corpus-io/dm3 into ens-a…
Bhupesh-mfsi Jul 10, 2024
bbae678
replaced XMLHttpRequest with axios
Bhupesh-mfsi Jul 11, 2024
408ae75
removed react package from messenger-web due to conflicting version
Bhupesh-mfsi Jul 12, 2024
4d127a9
use messageId input instead of sha256
AlexNi245 Jul 12, 2024
b274877
Merge pull request #1090 from dm3-org/messenger-web-fix
AlexNi245 Jul 12, 2024
1a319e2
clean up
AlexNi245 Jul 12, 2024
39ba931
clean up tests
AlexNi245 Jul 12, 2024
1a0da75
fix broken test
AlexNi245 Jul 12, 2024
b3dc03d
remove console.log from storage test
AlexNi245 Jul 15, 2024
f79413f
remove console.log from storage
AlexNi245 Jul 15, 2024
2545d16
clena up getCloudStorage
AlexNi245 Jul 15, 2024
6f35669
fixed messenger-web issue
Bhupesh-mfsi Jul 15, 2024
57dff11
Merge branch 'develop' of https://github.com/corpus-io/dm3 into messe…
Bhupesh-mfsi Jul 15, 2024
c80043d
Merge pull request #1092 from dm3-org/messenger-web-fix
malteish Jul 15, 2024
bcbe069
Merge remote-tracking branch 'dm3-org/develop' into DSFE3-Halt-delivery
AlexNi245 Jul 15, 2024
802882f
optimize imports
AlexNi245 Jul 15, 2024
2c59228
Merge pull request #1086 from dm3-org/ens-avatar-fix
AlexNi245 Jul 15, 2024
344165d
Merge pull request #1079 from dm3-org/DSFE3-Halt-delivery
AlexNi245 Jul 15, 2024
da7a016
Merge branch 'testing' into fix/prismaMigrateDeploy2
malteish Jul 15, 2024
038236a
added peer dependecy to msg-web to automatically handle version
Bhupesh-mfsi Jul 15, 2024
864c901
Merge branch 'develop' into fix/prismaMigrateDeploy2
malteish Jul 15, 2024
49d96bc
prettified
Bhupesh-mfsi Jul 15, 2024
cba95f2
Merge pull request #1093 from dm3-org/messenger-web-fix
malteish Jul 15, 2024
acf8566
Merge remote-tracking branch 'origin/develop' into fix/prismaMigrateD…
malteish Jul 15, 2024
a4bb539
reverted back to old messenger-web
Bhupesh-mfsi Jul 15, 2024
737cc57
Merge branch 'develop' of https://github.com/corpus-io/dm3 into messe…
Bhupesh-mfsi Jul 15, 2024
2cf0727
Merge pull request #1094 from dm3-org/messenger-web-fix
Bhupesh-mfsi Jul 15, 2024
b3615e9
Merge remote-tracking branch 'dm3-org/develop' into remove-pending-fr…
AlexNi245 Jul 15, 2024
849495a
Merge remote-tracking branch 'origin/develop' into fix/prismaMigrateD…
malteish Jul 15, 2024
5b7fb4c
Merge pull request #979 from dm3-org/remove-pending-from-BE-and-DS
AlexNi245 Jul 15, 2024
20cc981
Merge remote-tracking branch 'origin/develop' into fix/prismaMigrateD…
malteish Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:

jobs:
messenger-web-deploy:
environment: ${{ github.ref_name == 'main' && 'prod' || (github.ref == 'develop' && 'staging' || 'testing') }}
environment: ${{ github.ref_name == 'main' && 'prod' || (github.ref_name == 'develop' && 'staging' || 'testing') }}
runs-on: ubuntu-latest
env:
environment_name: ${{ github.ref_name == 'main' && 'prod' || (github.ref == 'develop' && 'staging' || 'testing') }}
environment_name: ${{ github.ref_name == 'main' && 'prod' || (github.ref_name == 'develop' && 'staging' || 'testing') }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"scripts": {
"docker:up": "docker-compose up -d",
"prisma-init": "prisma generate && prisma migrate dev ",
"prisma-init": "prisma generate && prisma migrate deploy ",
"start": "yarn prisma-init && node ./dist/index.js",
"start-inspect": "node --inspect=0.0.0.0:9229 ./dist/index.js",
"test": "yarn run before:tests && DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests?schema=public' yarn jest --coverage --runInBand --transformIgnorePatterns 'node_modules/(?!(dm3-lib-\\w*)/)'",
Expand Down
9 changes: 0 additions & 9 deletions packages/backend/src/persistence/getDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ISessionDatabase } from '@dm3-org/dm3-lib-server-side';
import { UserStorage } from '@dm3-org/dm3-lib-storage';
import { PrismaClient } from '@prisma/client';
import { createClient } from 'redis';
import Pending from './pending';
import Session from './session';
import Storage from './storage';
import { ConversationRecord } from './storage/postgres/dto/ConversationRecord';
Expand All @@ -15,7 +14,6 @@ export enum RedisPrefix {
Sync = 'sync:',
Session = 'session:',
UserStorage = 'user.storage:',
Pending = 'pending:',
NotificationChannel = 'notificationChannel:',
GlobalNotification = 'globalNotification:',
Otp = 'otp:',
Expand Down Expand Up @@ -69,10 +67,6 @@ export async function getDatabase(
//Legacy remove after storage has been merged
getUserStorage: Storage.getUserStorageOld(redis),
setUserStorage: Storage.setUserStorageOld(redis),
//Pending
addPending: Pending.addPending(redis),
getPending: Pending.getPending(redis),
deletePending: Pending.deletePending(redis),
//Storage AddConversation
addConversation: Storage.addConversation(prisma),
getConversationList: Storage.getConversationList(prisma),
Expand Down Expand Up @@ -110,9 +104,6 @@ export interface IDatabase extends ISessionDatabase {
//Legacy remove after storage has been merged
getUserStorage: (ensName: string) => Promise<UserStorage | null>;
setUserStorage: (ensName: string, data: string) => Promise<void>;
addPending: (ensName: string, contactEnsName: string) => Promise<void>;
getPending: (ensName: string) => Promise<string[]>;
deletePending: (ensName: string) => Promise<void>;

addConversation: (
ensName: string,
Expand Down
11 changes: 0 additions & 11 deletions packages/backend/src/persistence/pending/addPending.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/backend/src/persistence/pending/deletePending.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/backend/src/persistence/pending/getPending.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/backend/src/persistence/pending/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const clearHaltedMessage =
const message = await db.encryptedMessage.findFirst({
where: {
id: messageId,
ownerId: account.id,
},
});

Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ describe('Profile', () => {
setSession: async (_: string, __: any) => {
return (_: any, __: any, ___: any) => {};
},
getPending: (_: any) => [],
getIdEnsName: async (ensName: string) => ensName,
};

Expand Down
13 changes: 2 additions & 11 deletions packages/backend/src/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,6 @@ describe('Storage', () => {
})
.send();

console.log(body);

expect(body.length).toBe(1);
expect(body[0].contact).toEqual(sha256(receiver.account.ensName));
expect(JSON.parse(body[0].previewMessage)).toEqual(envelop3);
Expand All @@ -508,8 +506,6 @@ describe('Storage', () => {
})
.send();

console.log(body);

expect(status).toBe(400);
});

Expand All @@ -522,8 +518,6 @@ describe('Storage', () => {
})
.send();

console.log(body);

expect(status).toBe(400);
});
});
Expand Down Expand Up @@ -980,7 +974,7 @@ describe('Storage', () => {
.send({
encryptedEnvelopContainer: JSON.stringify(envelop1),
encryptedContactName: sha256(receiver.account.ensName),
messageId: '123',
messageId: envelop1.metadata.encryptedMessageHash,
createdAt: 1,
isHalted: true,
});
Expand All @@ -1007,7 +1001,7 @@ describe('Storage', () => {
authorization: 'Bearer ' + token,
})
.send({
messageId: 123,
messageId: messages[0].messageId,
});

expect(deleteStatus).toBe(200);
Expand Down Expand Up @@ -1162,9 +1156,6 @@ describe('Storage', () => {
isHalted: false,
});

console.log('xxxx', x.status);
console.log('xxxx', x.body);

await request(app)
.post(`/new/bob.eth/addMessage`)
.set({
Expand Down
12 changes: 1 addition & 11 deletions packages/backend/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,12 @@ export default (
}

const ensName = normalizeEnsName(req.params.ensName);
//Since the message is fully encrypted, we cannot use the messageHash as an identifier.
//Instead we use the hash of the ensName and the messageId to have a unique identifier
const uniqueMessageId = sha256(ensName + messageId);

console.log(
'clearHaltedMessage uniqueMessageId ',
uniqueMessageId,
ensName,
messageId,
);

const success = await db.clearHaltedMessage(
ensName,
//If the aliasName is not provided, we use the ensName as the client has no intention to use an alias
aliasName,
uniqueMessageId,
messageId,
);

if (success) {
Expand Down
43 changes: 0 additions & 43 deletions packages/delivery-service/src/delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,6 @@ describe('Delivery', () => {
});
});

describe('getPendingMessages', () => {
it('Returns 200 if schema is valid', async () => {
const web3Provider = {
resolveName: async () =>
'0x99C19AB10b9EC8aC6fcda9586E81f6B73a298870',
};

const token = await createAuthToken(
'0x99C19AB10b9EC8aC6fcda9586E81f6B73a298870',
);

const db = {
getSession: async (ensName: string) => ({
challenge: 'deprecated challenge',
token: 'deprecated token that is not used anymore',
}),
setSession: async (_: string, __: any) => {
return (_: any, __: any, ___: any) => {};
},
getPending: (_: any) => [],
deletePending: (_: any) => [],
getIdEnsName: async (ensName: string) => ensName,
};
const app = express();
app.use(bodyParser.json());
app.use(
delivery(web3Provider as any, db as any, keysA, serverSecret),
);

const { status } = await request(app)
.post(
'/messages/0x99C19AB10b9EC8aC6fcda9586E81f6B73a298870/pending',
)
.set({
authorization: `Bearer ${token}`,
})

.send();

expect(status).toBe(200);
});
});

describe('syncAcknoledgment', () => {
it('Returns 200 if schema is valid', async () => {
const web3Provider = {
Expand Down
14 changes: 1 addition & 13 deletions packages/delivery-service/src/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default (
req.params.ensName,
//Fetch the last 10 messages per conversation
//If we decide to add pagination for that endpoint we can pass this value as a param
10,
1000,
);
res.json(incomingMessages);
} catch (e) {
Expand All @@ -97,18 +97,6 @@ export default (
},
);

router.post('/messages/:ensName/pending', async (req, res, next) => {
try {
const account = await db.getIdEnsName(req.params.ensName);
const pending = await db.getPending(account);
await db.deletePending(account);

res.json(pending);
} catch (e) {
next(e);
}
});

//TODO remove after storage refactoring
router.post(
'/messages/:ensName/syncAcknoledgment/:last_message_pull',
Expand Down
33 changes: 0 additions & 33 deletions packages/delivery-service/src/messaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,37 +249,4 @@ describe('Messaging', () => {
)(getSocketMock());
});
});

describe('pendingMessage', () => {
it('returns error if schema is invalid', async () => {
const data = {
accountAddress: '',
contactAddress: '',
};
const callback = jest.fn((e: any) => {
if (e.error !== 'invalid schema') {
throw Error(e);
}
expect(e.error).toBe('invalid schema');
});
const getSocketMock = jest.fn(() => {
return {
on: async (name: string, onPendingMessage: any) => {
//We just want to test the submitMessage callback fn
if (name === 'pendingMessage') {
await onPendingMessage(data, callback);
}
},
} as unknown as Socket;
});
onConnection(
io as any,
web3Provider as any,
db as any,
keysA,
serverSecret,
mockWsManager,
)(getSocketMock());
});
});
});
Loading
Loading