Skip to content

Commit

Permalink
Merge pull request #29814 from RocketChat/release-6.2.10
Browse files Browse the repository at this point in the history
Release 6.2.10
  • Loading branch information
sampaiodiego authored Jul 13, 2023
2 parents abf7467 + bed945c commit 26d00d3
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 115 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-crabs-deliver.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .changeset/fuzzy-parents-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix Toggle message box formatting toolbar on click
5 changes: 5 additions & 0 deletions .changeset/nine-yaks-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/release-action': minor
---

Use `release-automation` branch to perform the release
2 changes: 2 additions & 0 deletions .changeset/ninety-cats-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
47 changes: 0 additions & 47 deletions .github/workflows/changesets.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CI_PAT }}

- name: Setup NodeJS
Expand All @@ -29,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
Expand Down
19 changes: 18 additions & 1 deletion apps/meteor/app/apps/server/converters/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
};
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ const FormattingToolbarDropdown = ({ composer, items, ...props }: FormattingTool
};

return (
<Option key={index} onClick={handleFormattingAction}>
<Option
key={index}
onClick={() => {
handleFormattingAction();
toggle();
}}
>
<OptionIcon name={'icon' in formatter ? formatter.icon : 'link'} />
<OptionContent>{t(formatter.label)}</OptionContent>
</Option>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/core-typings/src/IInquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions packages/release-action/src/bumpNextVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
38 changes: 37 additions & 1 deletion packages/release-action/src/gitUtils.ts
Original file line number Diff line number Diff line change
@@ -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', '"[email protected]"']);
}

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}`]);
}
2 changes: 1 addition & 1 deletion packages/release-action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
25 changes: 17 additions & 8 deletions packages/release-action/src/publishRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ 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,
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);
Expand All @@ -29,12 +30,12 @@ export async function publishRelease({
await createNpmFile();

if (baseRef) {
await exec('git', ['checkout', baseRef]);
await checkoutBranch(baseRef);
}

const { version: currentVersion } = await readPackageJson(cwd);

if (exitCandidate) {
if (mergeFinal) {
let preRelease = false;
try {
fs.accessSync(path.resolve(cwd, '.changeset', 'pre.json'));
Expand Down Expand Up @@ -73,17 +74,25 @@ 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}`);

if (mergeFinal) {
// 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({
Expand Down
Loading

0 comments on commit 26d00d3

Please sign in to comment.