From f855aaf6208279d2dd9f8240ab156f80649a94b7 Mon Sep 17 00:00:00 2001 From: rocketchat-github-ci Date: Thu, 13 Jul 2023 14:37:05 +0000 Subject: [PATCH 1/5] 6.2.10 --- .changeset/ninety-cats-arrive.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/ninety-cats-arrive.md diff --git a/.changeset/ninety-cats-arrive.md b/.changeset/ninety-cats-arrive.md new file mode 100644 index 000000000000..a845151cc840 --- /dev/null +++ b/.changeset/ninety-cats-arrive.md @@ -0,0 +1,2 @@ +--- +--- From ef4cd97c6135a25a33fa679d90434b05dd616e50 Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:38:28 +0530 Subject: [PATCH 2/5] fix: Toggle message box formatting toolbar on click (#29727) Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .changeset/fuzzy-parents-drop.md | 5 +++++ .../FormattingToolbarDropdown.tsx | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/fuzzy-parents-drop.md diff --git a/.changeset/fuzzy-parents-drop.md b/.changeset/fuzzy-parents-drop.md new file mode 100644 index 000000000000..93646c6c2cfc --- /dev/null +++ b/.changeset/fuzzy-parents-drop.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fix Toggle message box formatting toolbar on click diff --git a/apps/meteor/client/views/room/components/body/composer/messageBox/MessageBoxFormattingToolbar/FormattingToolbarDropdown.tsx b/apps/meteor/client/views/room/components/body/composer/messageBox/MessageBoxFormattingToolbar/FormattingToolbarDropdown.tsx index e44c2521616a..bdee3ce6d7d1 100644 --- a/apps/meteor/client/views/room/components/body/composer/messageBox/MessageBoxFormattingToolbar/FormattingToolbarDropdown.tsx +++ b/apps/meteor/client/views/room/components/body/composer/messageBox/MessageBoxFormattingToolbar/FormattingToolbarDropdown.tsx @@ -34,7 +34,13 @@ const FormattingToolbarDropdown = ({ composer, items, ...props }: FormattingTool }; return ( - From 2a09b648b94454ff29d35ac43642bfd94bc4d80f Mon Sep 17 00:00:00 2001 From: Murtaza Patrawala <34130764+murtaza98@users.noreply.github.com> Date: Tue, 11 Jul 2023 00:06:50 +0530 Subject: [PATCH 3/5] fix: Prevent app's bridges from overriding lastMsg prop on rooms col (#29756) Co-authored-by: Gabriel Casals <83978645+casalsgh@users.noreply.github.com> Co-authored-by: Kevin Aleman --- .changeset/dirty-crabs-deliver.md | 5 +++++ .../app/apps/server/converters/rooms.js | 19 ++++++++++++++++++- .../server/hooks/saveLastVisitorMessageTs.ts | 3 +++ packages/core-typings/src/IInquiry.ts | 3 +++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .changeset/dirty-crabs-deliver.md diff --git a/.changeset/dirty-crabs-deliver.md b/.changeset/dirty-crabs-deliver.md new file mode 100644 index 000000000000..374d10e37530 --- /dev/null +++ b/.changeset/dirty-crabs-deliver.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +fix: Prevent app's bridges from overriding the lastMsg prop which further was affecting Omni-Visitor abandonment feature for app diff --git a/apps/meteor/app/apps/server/converters/rooms.js b/apps/meteor/app/apps/server/converters/rooms.js index 8fc74ac21c9a..44d513bd591d 100644 --- a/apps/meteor/app/apps/server/converters/rooms.js +++ b/apps/meteor/app/apps/server/converters/rooms.js @@ -38,11 +38,16 @@ export class AppRoomsConverter { let v; if (room.visitor) { const visitor = await LivechatVisitors.findOneById(room.visitor.id); + + const lastMessageTs = room?.visitor?.lastMessageTs; + const phone = room?.visitor?.channelPhone; v = { _id: visitor._id, username: visitor.username, token: visitor.token, status: visitor.status || 'online', + ...(lastMessageTs && { lastMessageTs }), + ...(phone && { phone }), }; } @@ -172,9 +177,21 @@ export class AppRoomsConverter { return undefined; } + const { lastMessageTs, phone } = v; + delete room.v; - return this.orch.getConverters().get('visitors').convertById(v._id); + return { + ...(await this.orch.getConverters().get('visitors').convertById(v._id)), + // Note: room.v is not just visitor, it also contains channel related visitor data + // so we need to pass this data to the converter + // So suppose you have a contact whom we're contacting using SMS via 2 phone no's, + // let's call X and Y. Then if the contact sends a message using X phone number, + // then room.v.phoneNo would be X and correspondingly we'll store the timestamp of + // the last message from this visitor from X phone no on room.v.lastMessageTs + ...(phone && { channelPhone: phone }), + ...(lastMessageTs && { lastMessageTs }), + }; }, department: async (room) => { const { departmentId } = room; diff --git a/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts b/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts index b6273c0f3e74..1dabee3b8c03 100644 --- a/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts +++ b/apps/meteor/app/livechat/server/hooks/saveLastVisitorMessageTs.ts @@ -9,6 +9,9 @@ callbacks.add( if (!(isOmnichannelRoom(room) && room.v.token)) { return message; } + if (message.t) { + return message; + } if (message.token) { await LivechatRooms.setVisitorLastMessageTimestampByRoomId(room._id, message.ts); } diff --git a/packages/core-typings/src/IInquiry.ts b/packages/core-typings/src/IInquiry.ts index 521f4b8537c2..1d5d41b482bf 100644 --- a/packages/core-typings/src/IInquiry.ts +++ b/packages/core-typings/src/IInquiry.ts @@ -18,6 +18,9 @@ export enum LivechatInquiryStatus { OPEN = 'open', } +// This is a subset of the IVisitor interface + channel related fields +// IMPORTANT: If you're adding a new field here, make sure to update the +// apps-engine's room converter to include it too export interface IVisitor { _id: string; username: string; From 63c91f24a95946d1ae65f53ec0e38d8494df9d04 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Thu, 6 Jul 2023 23:24:05 -0300 Subject: [PATCH 4/5] ci: Improve release automation (#29752) --- .changeset/nine-yaks-draw.md | 5 ++ .github/workflows/changesets.yml | 47 ------------------- .github/workflows/publish-release.yml | 1 + package.json | 1 - .../release-action/src/bumpNextVersion.ts | 10 ++-- .../src/fixWorkspaceVersionsBeforePublish.ts | 4 -- packages/release-action/src/gitUtils.ts | 38 ++++++++++++++- packages/release-action/src/publishRelease.ts | 17 +++++-- yarn.lock | 45 +----------------- 9 files changed, 61 insertions(+), 107 deletions(-) create mode 100644 .changeset/nine-yaks-draw.md delete mode 100644 .github/workflows/changesets.yml diff --git a/.changeset/nine-yaks-draw.md b/.changeset/nine-yaks-draw.md new file mode 100644 index 000000000000..bd12a98350fb --- /dev/null +++ b/.changeset/nine-yaks-draw.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/release-action': minor +--- + +Use `release-automation` branch to perform the release diff --git a/.github/workflows/changesets.yml b/.github/workflows/changesets.yml deleted file mode 100644 index 5cd75fa68cf7..000000000000 --- a/.github/workflows/changesets.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Changesets - -on: - push: - branches: - - develop - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -jobs: - release-versions: - name: ⚙️ Variables Setup - runs-on: ubuntu-latest - outputs: - node-version: ${{ steps.var.outputs.node-version }} - steps: - - uses: Bhacaz/checkout-files@v2 - with: - files: package.json - branch: ${{ github.ref }} - - - id: var - run: | - NODE_VERSION=$(node -p "require('./package.json').engines.node") - echo "NODE_VERSION: ${NODE_VERSION}" - echo "node-version=${NODE_VERSION}" >> $GITHUB_OUTPUT - - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Setup NodeJS - uses: ./.github/actions/setup-node - with: - node-version: ${{ needs.release-versions.outputs.node-version }} - cache-modules: true - install: true - - - name: Create Release Pull Request - uses: changesets/action@v1 - with: - title: 'chore: Bump packages' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 3def1c819fb1..6234889d7ac8 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -18,6 +18,7 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 with: + fetch-depth: 0 token: ${{ secrets.CI_PAT }} - name: Setup NodeJS diff --git a/package.json b/package.json index f12f83ec5e71..50e38a60f0d5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "fuselage": "./fuselage.sh" }, "devDependencies": { - "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.1", "@types/chart.js": "^2.9.37", "@types/js-yaml": "^4.0.5", diff --git a/packages/release-action/src/bumpNextVersion.ts b/packages/release-action/src/bumpNextVersion.ts index 1184209062ef..999fa3d7b49b 100644 --- a/packages/release-action/src/bumpNextVersion.ts +++ b/packages/release-action/src/bumpNextVersion.ts @@ -9,6 +9,7 @@ import { setupOctokit } from './setupOctokit'; import { createNpmFile } from './createNpmFile'; import { getChangelogEntry, bumpFileVersions, readPackageJson } from './utils'; import { fixWorkspaceVersionsBeforePublish } from './fixWorkspaceVersionsBeforePublish'; +import { commitChanges, createBranch, createTag, pushNewBranch } from './gitUtils'; export async function bumpNextVersion({ githubToken, @@ -59,19 +60,18 @@ export async function bumpNextVersion({ await bumpFileVersions(cwd, currentVersion, newVersion); // TODO check if branch exists - await exec('git', ['checkout', '-b', newBranch]); + await createBranch(newBranch); - await exec('git', ['add', '.']); - await exec('git', ['commit', '-m', newVersion]); + await commitChanges(`Release ${newVersion}`); core.info('fix dependencies in workspace packages'); await fixWorkspaceVersionsBeforePublish(); await exec('yarn', ['changeset', 'publish', '--no-git-tag']); - await exec('git', ['tag', newVersion]); + await createTag(newVersion); - await exec('git', ['push', '--force', '--follow-tags', 'origin', `HEAD:refs/heads/${newBranch}`]); + await pushNewBranch(newBranch); if (newVersion.includes('rc.0')) { const finalPrTitle = `Release ${finalVersion}`; diff --git a/packages/release-action/src/fixWorkspaceVersionsBeforePublish.ts b/packages/release-action/src/fixWorkspaceVersionsBeforePublish.ts index 1a5780996fef..3a45e4fb8794 100644 --- a/packages/release-action/src/fixWorkspaceVersionsBeforePublish.ts +++ b/packages/release-action/src/fixWorkspaceVersionsBeforePublish.ts @@ -41,10 +41,6 @@ export async function fixWorkspaceVersionsBeforePublish() { for (const dependency of dependencies) { const dependencyVersion = packageJson[dependencyType][dependency]; if (dependencyVersion.startsWith('workspace:')) { - if (!dependencyVersion.startsWith('workspace:^')) { - throw new Error(`Unsupported workspace version range: ${dependencyVersion}`); - } - const realVersion = workspaceVersions.get(dependency); if (!realVersion) { throw new Error(`Could not find version for workspace ${dependency}`); diff --git a/packages/release-action/src/gitUtils.ts b/packages/release-action/src/gitUtils.ts index 0550841f2810..808f6d8885fa 100644 --- a/packages/release-action/src/gitUtils.ts +++ b/packages/release-action/src/gitUtils.ts @@ -1,6 +1,42 @@ -import { exec } from '@actions/exec'; +import { exec, getExecOutput } from '@actions/exec'; export async function setupGitUser() { await exec('git', ['config', 'user.name', '"rocketchat-github-ci"']); await exec('git', ['config', 'user.email', '"buildmaster@rocket.chat"']); } + +export async function createBranch(newBranch: string) { + await exec('git', ['checkout', '-b', newBranch]); +} + +export async function checkoutBranch(branchName: string) { + await exec('git', ['checkout', branchName]); +} + +export async function mergeBranch(branchName: string) { + await exec('git', ['merge', '--no-edit', branchName]); +} + +export async function commitChanges(commitMessage: string) { + await exec('git', ['add', '.']); + await exec('git', ['commit', '-m', commitMessage]); +} + +export async function createTag(version: string) { + // create an annotated tag so git push --follow-tags will push the tag + await exec('git', ['tag', version, '-m', version]); +} + +export async function getCurrentBranch() { + const { stdout: branchName } = await getExecOutput('git', ['rev-parse', '--abbrev-ref', 'HEAD']); + + return branchName.trim(); +} + +export async function pushChanges() { + await exec('git', ['push', '--follow-tags']); +} + +export async function pushNewBranch(newBranch: string) { + await exec('git', ['push', '--force', '--follow-tags', 'origin', `HEAD:refs/heads/${newBranch}`]); +} diff --git a/packages/release-action/src/publishRelease.ts b/packages/release-action/src/publishRelease.ts index 081d38237a24..c828d86c2087 100644 --- a/packages/release-action/src/publishRelease.ts +++ b/packages/release-action/src/publishRelease.ts @@ -9,6 +9,7 @@ import { createNpmFile } from './createNpmFile'; import { setupOctokit } from './setupOctokit'; import { bumpFileVersions, getChangelogEntry, readPackageJson } from './utils'; import { fixWorkspaceVersionsBeforePublish } from './fixWorkspaceVersionsBeforePublish'; +import { checkoutBranch, commitChanges, createTag, getCurrentBranch, mergeBranch, pushChanges } from './gitUtils'; export async function publishRelease({ githubToken, @@ -29,7 +30,7 @@ export async function publishRelease({ await createNpmFile(); if (baseRef) { - await exec('git', ['checkout', baseRef]); + await checkoutBranch(baseRef); } const { version: currentVersion } = await readPackageJson(cwd); @@ -73,17 +74,23 @@ export async function publishRelease({ core.info('update version in all files to new'); await bumpFileVersions(cwd, currentVersion, newVersion); - await exec('git', ['add', '.']); - await exec('git', ['commit', '-m', `Release ${newVersion}`]); + await commitChanges(`Release ${newVersion}`); + + // get current branch name + const branchName = await getCurrentBranch(); + + // merge release changes to master + await checkoutBranch('master'); + await mergeBranch(branchName); core.info('fix dependencies in workspace packages'); await fixWorkspaceVersionsBeforePublish(); await exec('yarn', ['changeset', 'publish', '--no-git-tag']); - await exec('git', ['tag', newVersion]); + await createTag(newVersion); - await exec('git', ['push', '--follow-tags']); + await pushChanges(); core.info('create draft release'); await octokit.rest.repos.createRelease({ diff --git a/yarn.lock b/yarn.lock index dd3fad203027..53f80f04a7e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2688,17 +2688,6 @@ __metadata: languageName: node linkType: hard -"@changesets/changelog-github@npm:^0.4.8": - version: 0.4.8 - resolution: "@changesets/changelog-github@npm:0.4.8" - dependencies: - "@changesets/get-github-info": ^0.5.2 - "@changesets/types": ^5.2.1 - dotenv: ^8.1.0 - checksum: 8a357cc08757e0eeca267ee05141f68bef936582abef8b78a5d30d99f5a86e41b7d3debba70992b73b2f57b0fc6201ec1cc3c65116930167ee3197b427b865c5 - languageName: node - linkType: hard - "@changesets/cli@npm:^2.26.1": version: 2.26.1 resolution: "@changesets/cli@npm:2.26.1" @@ -2779,16 +2768,6 @@ __metadata: languageName: node linkType: hard -"@changesets/get-github-info@npm:^0.5.2": - version: 0.5.2 - resolution: "@changesets/get-github-info@npm:0.5.2" - dependencies: - dataloader: ^1.4.0 - node-fetch: ^2.5.0 - checksum: 067e07eeaecdbedbd1c715513c4aa6206a941bd1d3af292d067792808c6fa6644caad2b35fba614a44892559c031c234df8028f8d2abd4cb2682d48080ef5df3 - languageName: node - linkType: hard - "@changesets/get-release-plan@npm:^3.0.16": version: 3.0.16 resolution: "@changesets/get-release-plan@npm:3.0.16" @@ -17215,13 +17194,6 @@ __metadata: languageName: node linkType: hard -"dataloader@npm:^1.4.0": - version: 1.4.0 - resolution: "dataloader@npm:1.4.0" - checksum: e2c93d43afde68980efc0cd9ff48e9851116e27a9687f863e02b56d46f7e7868cc762cd6dcbaf4197e1ca850a03651510c165c2ae24b8e9843fd894002ad0e20 - languageName: node - linkType: hard - "date-fns@npm:^2.15.0, date-fns@npm:^2.28.0": version: 2.28.0 resolution: "date-fns@npm:2.28.0" @@ -18120,7 +18092,7 @@ __metadata: languageName: node linkType: hard -"dotenv@npm:^8.0.0, dotenv@npm:^8.1.0": +"dotenv@npm:^8.0.0": version: 8.6.0 resolution: "dotenv@npm:8.6.0" checksum: 38e902c80b0666ab59e9310a3d24ed237029a7ce34d976796349765ac96b8d769f6df19090f1f471b77a25ca391971efde8a1ea63bb83111bd8bec8e5cc9b2cd @@ -27835,20 +27807,6 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^2.5.0": - version: 2.6.11 - resolution: "node-fetch@npm:2.6.11" - dependencies: - whatwg-url: ^5.0.0 - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: 249d0666a9497553384d46b5ab296ba223521ac88fed4d8a17d6ee6c2efb0fc890f3e8091cafe7f9fba8151a5b8d925db2671543b3409a56c3cd522b468b47b3 - languageName: node - linkType: hard - "node-forge@npm:^0.10.0": version: 0.10.0 resolution: "node-forge@npm:0.10.0" @@ -32910,7 +32868,6 @@ __metadata: version: 0.0.0-use.local resolution: "rocket.chat@workspace:." dependencies: - "@changesets/changelog-github": ^0.4.8 "@changesets/cli": ^2.26.1 "@types/chart.js": ^2.9.37 "@types/js-yaml": ^4.0.5 From bed945cfc5bddb001ce4d510545bc1ec826e79d0 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Thu, 13 Jul 2023 11:20:44 -0300 Subject: [PATCH 5/5] regression(ci): Fix publish release automation (#29779) --- .github/workflows/new-release.yml | 2 +- .github/workflows/publish-release.yml | 2 +- packages/release-action/src/index.ts | 2 +- packages/release-action/src/publishRelease.ts | 18 ++++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml index de6d66473201..cc71a0f0cbc6 100644 --- a/.github/workflows/new-release.yml +++ b/.github/workflows/new-release.yml @@ -39,7 +39,7 @@ jobs: - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - - name: Build + - name: Build packages run: yarn build - name: Start next release diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 6234889d7ac8..1f2f83266eab 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -30,7 +30,7 @@ jobs: - uses: dtinth/setup-github-actions-caching-for-turbo@v1 - - name: Build + - name: Build packages run: yarn build - name: Publish final release diff --git a/packages/release-action/src/index.ts b/packages/release-action/src/index.ts index 1e2e446cfa66..89b3888e2e58 100644 --- a/packages/release-action/src/index.ts +++ b/packages/release-action/src/index.ts @@ -38,7 +38,7 @@ import { setupGitUser } from './gitUtils'; const mainPackagePath = path.join(cwd, 'apps', 'meteor'); if (action === 'publish-final') { - await publishRelease({ githubToken, exitCandidate: true, mainPackagePath }); + await publishRelease({ githubToken, mergeFinal: true, mainPackagePath }); } else if (action === 'publish') { await publishRelease({ githubToken, baseRef, mainPackagePath }); } else if (action === 'bump') { diff --git a/packages/release-action/src/publishRelease.ts b/packages/release-action/src/publishRelease.ts index c828d86c2087..7d396c55734e 100644 --- a/packages/release-action/src/publishRelease.ts +++ b/packages/release-action/src/publishRelease.ts @@ -14,14 +14,14 @@ import { checkoutBranch, commitChanges, createTag, getCurrentBranch, mergeBranch export async function publishRelease({ githubToken, mainPackagePath, - exitCandidate = false, + mergeFinal = false, baseRef, cwd = process.cwd(), }: { githubToken: string; mainPackagePath: string; baseRef?: string; - exitCandidate?: boolean; + mergeFinal?: boolean; cwd?: string; }) { const octokit = setupOctokit(githubToken); @@ -35,7 +35,7 @@ export async function publishRelease({ const { version: currentVersion } = await readPackageJson(cwd); - if (exitCandidate) { + if (mergeFinal) { let preRelease = false; try { fs.accessSync(path.resolve(cwd, '.changeset', 'pre.json')); @@ -76,12 +76,14 @@ export async function publishRelease({ await commitChanges(`Release ${newVersion}`); - // get current branch name - const branchName = await getCurrentBranch(); + if (mergeFinal) { + // get current branch name + const branchName = await getCurrentBranch(); - // merge release changes to master - await checkoutBranch('master'); - await mergeBranch(branchName); + // merge release changes to master + await checkoutBranch('master'); + await mergeBranch(branchName); + } core.info('fix dependencies in workspace packages'); await fixWorkspaceVersionsBeforePublish();