Skip to content

Commit

Permalink
🛠 Medium fixes part 2 (#1838)
Browse files Browse the repository at this point in the history
* Improve message options

* UI fixes

* Update Twake version

* Fix ephemeral message reception

* Ephemeral removal
  • Loading branch information
RomaricMourgues authored Dec 22, 2021
1 parent 419f090 commit 3cedad2
Show file tree
Hide file tree
Showing 30 changed files with 255 additions and 122 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/saas-update-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
deploy-php:
runs-on: ubuntu-20.04
steps:
- run: 'echo "DOCKERTAGVERSION=2021.Q3.735" >> $GITHUB_ENV'
- run: 'echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/develop')
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=develop" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/qa')
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=qa" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/canary')
run: 'echo "DOCKERTAG=canary" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=${{ env.DOCKERTAGVERSION }}-canary" >> $GITHUB_ENV'
Expand All @@ -40,13 +40,13 @@ jobs:
deploy-node:
runs-on: ubuntu-20.04
steps:
- run: 'echo "DOCKERTAGVERSION=2021.Q3.735" >> $GITHUB_ENV'
- run: 'echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/develop')
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=develop" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/qa')
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=qa" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/canary')
run: 'echo "DOCKERTAG=canary" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=${{ env.DOCKERTAGVERSION }}-canary" >> $GITHUB_ENV'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/saas-update-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ jobs:
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/qa' || github.ref == 'refs/heads/canary'
steps:
- run: 'echo "DOCKERTAGVERSION=2021.Q3.735" >> $GITHUB_ENV'
- run: 'echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/develop')
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=develop" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=develop" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/qa')
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=qa" >> $GITHUB_ENV'
run: 'echo "DOCKERTAG=qa" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=2021.Q4.846" >> $GITHUB_ENV'
- name: Set env to develop
if: endsWith(github.ref, '/canary')
run: 'echo "DOCKERTAG=canary" >> $GITHUB_ENV; echo "DOCKERTAGVERSION=${{ env.DOCKERTAGVERSION }}-canary" >> $GITHUB_ENV'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function removeMessage(Request $request)

$capabilities = [];

$group_id = $request->request->get("group_id", null);
$workspace_id = $request->request->get("workspace_id", null);

$application = $this->get("app.applications_api")->getAppFromRequest($request, $capabilities);
if (is_array($application) && $application["error"]) {
return new Response($application);
Expand All @@ -33,6 +36,8 @@ public function removeMessage(Request $request)
$object = $request->request->get("message", null);
$chan_id = $object["channel_id"];

$object["company_id"] = $group_id;
$object["worskpace_id"] = $workspace_id;
$result = $this->get("app.messages")->remove($object, $options);
$front_id = $result["front_id"];

Expand Down
6 changes: 3 additions & 3 deletions twake/backend/core/src/Twake/Core/Controller/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ function getVersion(Request $request)
"auth_mode" => array_keys($auth),
"auth" => $auth,
"version" => [
"current" => /* @VERSION_DETAIL */ "2021.Q3.735",
"current" => /* @VERSION_DETAIL */ "2021.Q4.846",
"minimal" => [
"web" => /* @MIN_VERSION_WEB */ "2021.Q3.735",
"mobile" => /* @MIN_VERSION_MOBILE */ "2021.Q3.735",
"web" => /* @MIN_VERSION_WEB */ "2021.Q4.846",
"mobile" => /* @MIN_VERSION_MOBILE */ "2021.Q4.846",
]
],
"elastic_search_available" => !!$this->container->getParameter("es.host"),
Expand Down
2 changes: 2 additions & 0 deletions twake/backend/core/src/Twake/Core/Services/AccessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public function getChannelCache($companyId, $workspaceId, $channelId){

$name = html_entity_decode($this->emojione_client->shortnameToUnicode($name), ENT_NOQUOTES, 'UTF-8');

$workspaceId = $workspaceId ?: $resChannel["workspace_id"];

$workspace = $this->doctrine->getRepository("Twake\Workspaces:Workspace")->findOneBy(Array("id" => $workspaceId));
$group = $this->doctrine->getRepository("Twake\Workspaces:Group")->findOneBy(Array("id" => $companyId));
$workspaceName = $workspace ? $workspace->getName() : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public function get($options, $current_user)

public function remove($object, $options, $current_user = null)
{
$channel = $this->getInfosFromChannel($object["company_id"], $object["workspace_id"], $object["channel_id"]);
$channel = $this->getInfosFromChannel($object["company_id"], $object["workspace_id"], $object["channel_id"]);
$channel["company_id"] = $channel["company_id"] ?? $object["company_id"];
$channel["workspace_id"] = $channel["workspace_id"] ?? $object["workspace_id"];

if(!$channel){
return;
}
Expand Down Expand Up @@ -290,9 +293,9 @@ public function convertFromNode($message, $channel){
return $array;
}

private function getInfosFromChannel($channelId){
private function getInfosFromChannel($companyId, $workspaceId, $channelId){

$this->access_manager->getChannelCache($channelId);
$this->access_manager->getChannelCache($companyId, $workspaceId, $channelId);

$channelDetails = $this->doctrine->getRepository("Twake\Core:CachedFromNode")->findOneBy(Array("company_id" => "unused", "type" => "channel", "key"=>$channelId));
if($channelDetails){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ public function notifyApp($app_id, $type, $event, $data)
"data" => $data
);

if(isset($event["data"]["message"])){
$event["data"]["message"]["channel_id"] = $event["data"]["message"]["cache"]["channel_id"];
$event["data"]["message"]["workspace_id"] = $event["data"]["message"]["cache"]["workspace_id"];
}

if (!$this->curl_rcx) {
$this->curl_rcx = new RollingCurlX(10);
$this->curl_rcx->setOptions([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class MessageToNotificationsProcessor {
sender: messageResource.user_id,
creation_date: messageResource.created_at,

mentions: mentions,
mentions,

sender_name: senderName,
channel_name: channel.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ export class ThreadMessagesService implements MessageThreadMessagesServiceAPI {
...pk,
});

msg.ephemeral = pk.ephemeral || {
id: pk.id,
version: "",
recipient: "",
recipient_context_id: "",
};

await this.onSaved(msg, { created: false }, context);

return new DeleteResult<Message>("message", msg, true);
Expand Down
6 changes: 3 additions & 3 deletions twake/backend/node/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
current: /* @VERSION_DETAIL */ "2021.Q3.735",
current: /* @VERSION_DETAIL */ "2021.Q4.846",
minimal: {
web: /* @MIN_VERSION_WEB */ "2021.Q3.735",
mobile: /* @MIN_VERSION_MOBILE */ "2021.Q3.735",
web: /* @MIN_VERSION_WEB */ "2021.Q4.846",
mobile: /* @MIN_VERSION_MOBILE */ "2021.Q4.846",
},
};
2 changes: 1 addition & 1 deletion twake/frontend/src/app/components/File/File.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
flex-direction: column;

.ant-tag {
height: 16px;
height: 15px;
line-height: 15px;
padding: 0 4px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ import UnverifiedAccount from './popups/UnverifiedAccount';
import BlockedAccount from './popups/BlockedAccount';
import UserService from 'services/user/UserService';
import InitService from 'app/services/InitService';
import { useCurrentUser } from 'app/state/recoil/hooks/useCurrentUser';

const AccountStatusComponent = (): JSX.Element => {
const user = UserService.getCurrentUser();
const { user } = useCurrentUser();
const maxUnverifiedDays =
InitService.server_infos?.configuration?.accounts?.console?.max_unverified_days || 7;
const oneDay = 1000 * 60 * 60 * 24;
const periodLimit = (user.created_at || 0) + maxUnverifiedDays * oneDay;
const periodLimit = (user?.created_at || 0) + maxUnverifiedDays * oneDay;
const daysLeft = Math.ceil((periodLimit - Date.now()) / oneDay);

if (InitService.server_infos?.configuration?.accounts?.type !== 'console') {
if (!user || InitService.server_infos?.configuration?.accounts?.type !== 'console') {
return <></>;
}

const showBlockedModal = () => {
if (InitService.server_infos?.configuration?.accounts?.type === 'console')
return ModalManager.open(
<BlockedAccount email={user.email} />,
<BlockedAccount email={user?.email} />,
{
position: 'center',
size: { width: '600px' },
Expand Down
7 changes: 6 additions & 1 deletion twake/frontend/src/app/components/Twacode/Compile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash';
import React from 'react';
import PseudoMarkdownCompiler from 'services/Twacode/pseudoMarkdownCompiler';
import { DynamicComponent } from './PseudoMarkdownDictionary';
Expand All @@ -24,6 +25,10 @@ const Compile = (props: Props) => {
if (typeof content === 'string') content = [content];
if (content.type || content.start) content = [content];

if (!_.isArray(content)) {
content = [content];
}

try {
return (
<>
Expand Down Expand Up @@ -76,7 +81,7 @@ const Compile = (props: Props) => {
return (
<span key={JSON.stringify(item) + index}>
<DynamicComponent
type={type.name}
type={type.name || item.type}
child={
<Compile
content={item.content || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const DynamicComponent = ({
eventContainer?: any;
textTransform?: any;
}) => {
console.log(type, child);

if (type === 'text_block_parent') {
return <span style={textTransform || {}}>{child}</span>;
}
Expand All @@ -32,7 +34,8 @@ export const DynamicComponent = ({
if (type === 'br') {
return (
<>
<br />,<span>{child}</span>,
<br />
<span>{child}</span>
</>
);
}
Expand All @@ -56,7 +59,8 @@ export const DynamicComponent = ({
const name = split[0];
return (
<>
<Chan id={id} name={name} />,<span> </span>,
<Chan id={id} name={name} />
<span> </span>
</>
);
}
Expand Down
4 changes: 2 additions & 2 deletions twake/frontend/src/app/environment/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
version: /* @VERSION */ '2021.Q3',
version_detail: /* @VERSION_DETAIL */ '2021.Q3.735',
version: /* @VERSION */ '2021.Q4',
version_detail: /* @VERSION_DETAIL */ '2021.Q4.846',
version_name: /* @VERSION_NAME */ 'Albatros',
};
5 changes: 4 additions & 1 deletion twake/frontend/src/app/models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type ThumbnailType = {
export type MessageFileMetadataSource = 'internal' | 'drive' | string;

export type MessageFileType = {
//
//Primary key
id?: string;
company_id?: string; // optional
Expand Down Expand Up @@ -185,7 +184,11 @@ export type NodeMessage = {

ephemeral: EphemeralMessage | null; //Used for non-persisted messages (like interractive messages)

//Used to display loader
_status?: 'sending' | 'failed' | 'sent' | 'cancelled';

//Used to display time separator
_previous_message?: NodeMessage;
};

export type MessageWithReplies = NodeMessage & {
Expand Down
3 changes: 2 additions & 1 deletion twake/frontend/src/app/scenes/Apps/Messages/Input/Input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@
.ephemerals {
text-align: left;

.thread-centerer {
.thread-section {
width: 100%;
padding-bottom: 8px;
.message {
padding: 0px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ export default (props: Props) => {
>
<EphemeralMessages
channelId={props.channelId || ''}
workspaceId={channel.workspace_id || ''}
threadId={props.threadId}
collectionKey={props.collectionKey || ''}
onHasEphemeralMessage={() => {
if (!hasEphemeralMessage) {
setHasEphemeralMessage(true);
Expand Down
Loading

0 comments on commit 3cedad2

Please sign in to comment.