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

Bump ua-parser-js from 0.7.31 to 0.7.33 in /twake/frontend #2705

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

729 changes: 0 additions & 729 deletions LICENSE.md

This file was deleted.

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ Twake offers all the features for collaboration :
- Video call and conferencing
- Real time document collaboration

<a href="https://twakeapp.com"><img width=800 src="https://github.com/linagora/Twake/raw/main/twake.png"/></a>
<a href="https://twake.app"><img width=800 src="https://github.com/linagora/Twake/raw/main/twake.png"/></a>

## Demo

You can <a href="https://twake.app"> try Twake</a> in SaaS.

Or run your own local Twake instance with :

```
cd twake
sudo ./start.sh
```bash
cd twake
export COMPOSE_FILE=docker-compose.onpremise.yml
docker compose up -d
```

Twake will be running on http//localhost and by default redirect to https and uses a self-signed certificate. If you want to run http only then set SSL_CERTS=none at docker-compose.yml
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Twake 2022.Q3.1120
# Twake 2022.Q4.1120

- Message delivery status 🟢
- New quote-reply feature ⤴️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ export default class KnowledgeGraphService

if (
this.kgAPIClient &&
(await this.shouldForwardEvent(data.resource.cache.companies, data.resource.id))
(await this.shouldForwardEvent(data.resource.cache?.companies || [], data.resource.id))
) {
for (const companyId of data.resource.cache.companies) {
for (const companyId of data.resource.cache?.companies || []) {
this.kgAPIClient.onUserCreated(companyId, data.resource);
}
}
Expand Down
7 changes: 6 additions & 1 deletion twake/backend/node/src/services/files/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ export class FileServiceImpl {
return entity;
}

async exists(id: string, companyId: string, context?: CompanyExecutionContext): Promise<boolean> {
const entity = await this.getFile({ id, company_id: companyId }, context);
return !!entity;
}

async download(
id: string,
context: CompanyExecutionContext,
Expand Down Expand Up @@ -242,7 +247,7 @@ export class FileServiceImpl {
return this.getFile({ id, company_id: context.company.id }, context);
}

async getFile(pk: Pick<File, "company_id" | "id">, context: ExecutionContext): Promise<File> {
async getFile(pk: Pick<File, "company_id" | "id">, context?: ExecutionContext): Promise<File> {
return this.repository.findOne(pk, {}, context);
}

Expand Down
61 changes: 36 additions & 25 deletions twake/backend/node/src/services/messages/services/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,31 +319,29 @@ export class ViewsServiceImpl implements TwakeServiceProvider, Initializable {
options: SearchMessageFilesOptions,
context?: ExecutionContext,
): Promise<ListResult<MessageFile>> {
return await this.searchFilesRepository
.search(
{
...(options.isFile ? { is_file: true } : {}),
...(options.isMedia ? { is_media: true } : {}),
const temp = await this.searchFilesRepository.search(
{
...(options.isFile ? { is_file: true } : {}),
...(options.isMedia ? { is_media: true } : {}),
},
{
pagination,
...(options.companyId ? { $in: [["cache_company_id", [options.companyId]]] } : {}),
...(options.workspaceId ? { $in: [["cache_workspace_id", [options.workspaceId]]] } : {}),
...(options.channelId ? { $in: [["cache_channel_id", [options.channelId]]] } : {}),
...(options.sender ? { $in: [["cache_user_id", [options.sender]]] } : {}),
...(options.extension ? { $in: [["extension", [options.extension]]] } : {}),
$text: {
$search: options.search,
},
{
pagination,
...(options.companyId ? { $in: [["cache_company_id", [options.companyId]]] } : {}),
...(options.workspaceId ? { $in: [["cache_workspace_id", [options.workspaceId]]] } : {}),
...(options.channelId ? { $in: [["cache_channel_id", [options.channelId]]] } : {}),
...(options.sender ? { $in: [["cache_user_id", [options.sender]]] } : {}),
...(options.extension ? { $in: [["extension", [options.extension]]] } : {}),
$text: {
$search: options.search,
},
$sort: {
created_at: "desc",
},
$sort: {
created_at: "desc",
},
context,
)
.then(a => {
return a;
});
},
context,
);

return new ListResult(temp.type, await this.checkFiles(temp.getEntities()), temp.nextPage);
}

async listUserMarkedFiles(
Expand Down Expand Up @@ -394,7 +392,7 @@ export class ViewsServiceImpl implements TwakeServiceProvider, Initializable {
const messageFilePromises: Promise<MessageFile & { context: MessageFileRef }>[] = refs.map(
async ref => {
try {
return {
const res = {
...(await this.repositoryMessageFile.findOne(
{
message_id: ref.message_id,
Expand All @@ -405,6 +403,8 @@ export class ViewsServiceImpl implements TwakeServiceProvider, Initializable {
)),
context: ref,
};

return res;
} catch (e) {
return null;
}
Expand Down Expand Up @@ -442,8 +442,19 @@ export class ViewsServiceImpl implements TwakeServiceProvider, Initializable {

return new ListResult<FileSearchResult>(
"file",
fileWithUserAndMessage,
await this.checkFiles(fileWithUserAndMessage),
nextPageUploads || nextPageDownloads,
);
}

async checkFiles<T extends MessageFile>(files: T[]): Promise<T[]> {
const results = await Promise.all(
files.map(async file => {
if (file.metadata.source !== "internal") return true;
const ei = file.metadata.external_id;
return await gr.services.files.exists(ei.id, ei.company_id);
}),
);
return files.filter((_v, index) => results[index]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ThreadExecutionContext,
} from "../../types";
import { handleError } from "../../../../utils/handleError";
import { Pagination } from "../../../../core/platform/framework/api/crud-service";
import { CrudException, Pagination } from "../../../../core/platform/framework/api/crud-service";
import { getThreadMessageWebsocketRoom } from "../realtime";
import { ThreadPrimaryKey } from "../../entities/threads";
import { extendExecutionContentWithChannel } from "./index";
Expand Down Expand Up @@ -74,6 +74,36 @@ export class MessagesController
throw "Message must be in a thread";
}

let hasOneMembership = false;
for (const participant of thread.participants) {
if (thread.created_by === context.user.id) {
hasOneMembership = true;
break;
}
if (participant.type === "channel") {
const isMember = await gr.services.channels.members.getChannelMember(
{ id: context.user.id },
{
company_id: participant.company_id,
workspace_id: participant.workspace_id,
id: participant.id,
},
);
if (isMember) {
hasOneMembership = true;
break;
}
} else if (participant.type === "user") {
if (participant.id === context.user.id) {
hasOneMembership = true;
break;
}
}
}
if (!hasOneMembership) {
throw CrudException.notFound("You can't post in this thread");
}

const result = await gr.services.messages.messages.save(
{
id: request.params.message_id || undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { handleError } from "../../../../utils/handleError";
import { CompanyExecutionContext } from "../../types";
import { ParticipantObject, Thread } from "../../entities/threads";
import gr from "../../../global-resolver";
import { CrudException } from "../../../../core/platform/framework/api/crud-service";

export class ThreadsController
implements
Expand Down Expand Up @@ -39,6 +40,27 @@ export class ThreadsController
reply: FastifyReply,
): Promise<ResourceCreateResponse<Thread>> {
const context = getCompanyExecutionContext(request);

const participants =
(request.body.resource.participants?.length
? request.body.resource?.participants
: request.body.options?.participants?.add) || [];
for (const participant of participants) {
if (participant.type === "channel") {
const isMember = await gr.services.channels.members.getChannelMember(
{ id: context.user.id },
{
company_id: participant.company_id,
workspace_id: participant.workspace_id,
id: participant.id,
},
);
if (!isMember) {
throw CrudException.notFound("Channel not found");
}
}
}

try {
const result = await gr.services.messages.threads.save(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { FastifyReply, FastifyRequest } from "fastify";
import { ResourceListResponse } from "../../../../utils/types";
import { Message } from "../../entities/messages";
import { handleError } from "../../../../utils/handleError";
import { ListResult, Pagination } from "../../../../core/platform/framework/api/crud-service";
import {
CrudException,
ListResult,
Pagination,
} from "../../../../core/platform/framework/api/crud-service";
import {
ChannelViewExecutionContext,
FlatFileFromMessage,
Expand Down Expand Up @@ -39,6 +43,18 @@ export class ViewsController {
const query = { ...request.query, include_users: request.query.include_users };
const context = getChannelViewExecutionContext(request);

const isMember = await gr.services.channels.members.getChannelMember(
{ id: context.user.id },
{
company_id: request.params.company_id,
workspace_id: request.params.workspace_id,
id: request.params.channel_id,
},
);
if (!isMember) {
throw CrudException.notFound("Channel not found");
}

let resources: ListResult<MessageWithReplies | FlatFileFromMessage | FlatPinnedFromMessage>;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@ export class NotificationPreferencesService implements TwakeServiceProvider, Ini
const notificationPreferences = (user?.preferences?.notifications || []).find(n => {
return n.company_id === pk.company_id && n.workspace_id === pk.workspace_id;
});
return notificationPreferences;
return (
notificationPreferences || {
company_id: pk.company_id,
workspace_id: pk.workspace_id,
preferences: {
highlight_words: [],
night_break: {
enable: false,
from: 0,
to: 0,
},
private_message_content: false,
mobile_notifications: "always",
email_notifications_delay: 15,
deactivate_notifications_until: 0,
notification_sound: "default",
},
}
);
}

/** We can define preferences for specifically a workspace or for all a company or all Twake
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/online/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class OnlineServiceImpl implements TwakeServiceProvider {
this.logger.debug(`Got an online:set request for ${(request.data || []).length} users`);

this.broadcastOnline(event, companies);
this.setLastSeenOnline([event.user.id], Date.now(), false);
this.setLastSeenOnline([event.user.id], Date.now(), true);
ack();
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class WorkspaceUsersCrudController
status: user.status_icon,
last_activity: user.last_activity,
cache: {
companies: user.cache.companies,
companies: user.cache?.companies || [],
},
companies: userCompanies
.filter(cu => companiesMap.get(cu.group_id))
Expand Down
Loading