Skip to content

Commit ab755c8

Browse files
Merge branch 'develop' of https://github.com/hcengineering/platform into staging-new
Signed-off-by: Artem Savchenko <armisav@gmail.com>
2 parents edbf10a + f56a483 commit ab755c8

File tree

36 files changed

+2098
-700
lines changed

36 files changed

+2098
-700
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

foundations/server/packages/middleware/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"dependencies": {
3838
"@hcengineering/core": "workspace:^0.7.24",
39+
"@hcengineering/contact": "workspace:^0.7.0",
3940
"@hcengineering/platform": "workspace:^0.7.19",
4041
"@hcengineering/server-core": "workspace:^0.7.18",
4142
"@hcengineering/query": "workspace:^0.7.17",

foundations/server/packages/middleware/src/guestPermissions.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type TxMiddlewareResult
66
} from '@hcengineering/server-core'
77
import core, {
8+
type Account,
89
AccountRole,
910
type Doc,
1011
hasAccountRole,
@@ -19,6 +20,7 @@ import core, {
1920
type TxUpdateDoc
2021
} from '@hcengineering/core'
2122
import platform, { PlatformError, Severity, Status } from '@hcengineering/platform'
23+
import contact, { type Person } from '@hcengineering/contact'
2224

2325
export class GuestPermissionsMiddleware extends BaseMiddleware implements Middleware {
2426
static async create (
@@ -40,44 +42,44 @@ export class GuestPermissionsMiddleware extends BaseMiddleware implements Middle
4042
}
4143

4244
for (const tx of txes) {
43-
this.processTx(ctx, tx)
45+
await this.processTx(ctx, tx)
4446
}
4547

4648
return await this.provideTx(ctx, txes)
4749
}
4850

49-
private processTx (ctx: MeasureContext<SessionData>, tx: Tx): void {
51+
private async processTx (ctx: MeasureContext<SessionData>, tx: Tx): Promise<void> {
5052
const h = this.context.hierarchy
5153
if (tx._class === core.class.TxApplyIf) {
5254
const applyTx = tx as TxApplyIf
5355
for (const t of applyTx.txes) {
54-
this.processTx(ctx, t)
56+
await this.processTx(ctx, t)
5557
}
5658
return
5759
}
5860
if (TxProcessor.isExtendsCUD(tx._class)) {
59-
const socialIds = ctx.contextData.account.socialIds
61+
const { account } = ctx.contextData
6062
const cudTx = tx as TxCUD<Doc>
6163
const isSpace = h.isDerived(cudTx.objectClass, core.class.Space)
6264
if (isSpace) {
63-
if (this.isForbiddenSpaceTx(cudTx as TxCUD<Space>, socialIds)) {
65+
if (await this.isForbiddenSpaceTx(ctx, cudTx as TxCUD<Space>, account)) {
6466
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
6567
}
66-
} else if (cudTx.space !== core.space.DerivedTx && this.isForbiddenTx(cudTx, socialIds)) {
68+
} else if (cudTx.space !== core.space.DerivedTx && (await this.isForbiddenTx(ctx, cudTx, account))) {
6769
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
6870
}
6971
}
7072
}
7173

72-
private isForbiddenTx (tx: TxCUD<Doc>, socialIds: PersonId[]): boolean {
74+
private async isForbiddenTx (ctx: MeasureContext, tx: TxCUD<Doc>, account: Account): Promise<boolean> {
7375
if (tx._class === core.class.TxMixin) return false
74-
return !this.hasMixinAccessLevel(tx, socialIds)
76+
return !(await this.hasMixinAccessLevel(ctx, tx, account))
7577
}
7678

77-
private isForbiddenSpaceTx (tx: TxCUD<Space>, socialIds: PersonId[]): boolean {
79+
private async isForbiddenSpaceTx (ctx: MeasureContext, tx: TxCUD<Space>, account: Account): Promise<boolean> {
7880
if (tx._class === core.class.TxRemoveDoc) return true
7981
if (tx._class === core.class.TxCreateDoc) {
80-
return !this.hasMixinAccessLevel(tx, socialIds)
82+
return !(await this.hasMixinAccessLevel(ctx, tx, account))
8183
}
8284
if (tx._class === core.class.TxUpdateDoc) {
8385
const updateTx = tx as TxUpdateDoc<Space>
@@ -93,7 +95,7 @@ export class GuestPermissionsMiddleware extends BaseMiddleware implements Middle
9395
return false
9496
}
9597

96-
private hasMixinAccessLevel (tx: TxCUD<Doc>, socialIds: PersonId[]): boolean {
98+
private async hasMixinAccessLevel (ctx: MeasureContext, tx: TxCUD<Doc>, account: Account): Promise<boolean> {
9799
const h = this.context.hierarchy
98100
const accessLevelMixin = h.classHierarchyMixin(tx.objectClass, core.mixin.TxAccessLevel)
99101
if (accessLevelMixin === undefined) return false
@@ -104,9 +106,15 @@ export class GuestPermissionsMiddleware extends BaseMiddleware implements Middle
104106
return accessLevelMixin.removeAccessLevel === AccountRole.Guest
105107
}
106108
if (tx._class === core.class.TxUpdateDoc) {
107-
if (accessLevelMixin.isIdentity === true && socialIds.includes(tx.objectId as unknown as PersonId)) {
109+
if (accessLevelMixin.isIdentity === true && account.socialIds.includes(tx.objectId as unknown as PersonId)) {
108110
return true
109111
}
112+
if (accessLevelMixin.isIdentity === true && h.isDerived(tx.objectClass, contact.class.Person)) {
113+
const person = (await this.findAll(ctx, tx.objectClass, { _id: tx.objectId }, { limit: 1 }))[0] as
114+
| Person
115+
| undefined
116+
return person?.personUuid === account.uuid
117+
}
110118
return accessLevelMixin.updateAccessLevel === AccountRole.Guest
111119
}
112120
return false

models/contact/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ export function createModel (builder: Builder): void {
325325
})
326326

327327
builder.mixin(contact.class.Person, core.class.Class, core.mixin.TxAccessLevel, {
328-
createAccessLevel: AccountRole.Guest
328+
createAccessLevel: AccountRole.Guest,
329+
isIdentity: true
329330
})
330331

331332
builder.mixin(contact.class.SocialIdentity, core.class.Class, core.mixin.TxAccessLevel, {

plugins/export-resources/src/export.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export async function exportToWorkspace (
5252
minor: 0,
5353
reviewers: [],
5454
controlledState: '',
55-
seqNumber: '$ensureUnique',
56-
code: '$ensureUnique'
55+
seqNumber: '$generateSeqNumber',
56+
code: '$generateCode'
5757
},
5858
'documents:class:DocumentMeta': {
5959
author: '$currentUser',

plugins/text-editor-assets/lang/cs.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
"ConvertToLinkPreview": "Zobrazit jako odkaz",
8080
"ConvertToEmbedPreview": "Zobrazit jako náhled obsahu",
8181
"UnableToLoadEmbeddedContent": "Náhled odkazu nelze načíst kvůli nastavení oprávnění nebo nepodporovanému obsahu",
82-
"CannotConnectToCollaborationService": "Nelze se připojit k službě spolupráce"
82+
"CannotConnectToCollaborationService": "Nelze se připojit k službě spolupráce",
83+
"SourceURL": "Zdrojová URL",
84+
"SelectedDocuments": "Vybrané dokumenty ({count, plural, =1 {1 položka} other {# položek}})"
8385
}
8486
}

plugins/text-editor-assets/lang/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
"ConvertToLinkPreview": "Als Link anzeigen",
7979
"ConvertToEmbedPreview": "Als Inhaltsvorschau anzeigen",
8080
"UnableToLoadEmbeddedContent": "Die Linkvorschau konnte aufgrund von Berechtigungseinstellungen oder nicht unterstütztem Inhalt nicht geladen werden",
81-
"CannotConnectToCollaborationService": "Kann keine Verbindung zum Kollaborationsdienst herstellen"
81+
"CannotConnectToCollaborationService": "Kann keine Verbindung zum Kollaborationsdienst herstellen",
82+
"SourceURL": "Quell-URL",
83+
"SelectedDocuments": "Ausgewählte Dokumente ({count, plural, =1 {1 Element} other {# Elemente}})"
8284
}
8385
}

plugins/text-editor-assets/lang/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
"ConvertToLinkPreview": "Show as a link",
8181
"ConvertToEmbedPreview": "Show as a content preview",
8282
"UnableToLoadEmbeddedContent": "Link preview couldn't be loaded due to permission settings or unsupported content",
83-
"CannotConnectToCollaborationService": "Cannot connect to collaboration service"
83+
"CannotConnectToCollaborationService": "Cannot connect to collaboration service",
84+
"SourceURL": "Source URL",
85+
"SelectedDocuments": "Selected documents ({count, plural, =1 {1 item} other {# items}})"
8486
}
8587
}

plugins/text-editor-assets/lang/es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"ConvertToLinkPreview": "Mostrar como enlace",
7070
"ConvertToEmbedPreview": "Mostrar como vista previa de contenido",
7171
"UnableToLoadEmbeddedContent": "No se pudo cargar la vista previa del enlace debido a la configuración de permisos o contenido no compatible",
72-
"CannotConnectToCollaborationService": "No se puede conectar con el colaborador"
72+
"CannotConnectToCollaborationService": "No se puede conectar con el colaborador",
73+
"SourceURL": "URL de origen",
74+
"SelectedDocuments": "Documentos seleccionados ({count, plural, =1 {1 elemento} other {# elementos}})"
7375
}
7476
}

plugins/text-editor-assets/lang/fr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"ConvertToLinkPreview": "Afficher comme lien",
7070
"ConvertToEmbedPreview": "Afficher comme aperçu de contenu",
7171
"UnableToLoadEmbeddedContent": "L’aperçu du lien n’a pas pu être chargé en raison des paramètres d’autorisation ou d’un contenu non pris en charge",
72-
"CannotConnectToCollaborationService": "Impossible de se connecter au collaborateur"
72+
"CannotConnectToCollaborationService": "Impossible de se connecter au collaborateur",
73+
"SourceURL": "URL source",
74+
"SelectedDocuments": "Documents sélectionnés ({count, plural, =1 {1 élément} other {# éléments}})"
7375
}
7476
}

0 commit comments

Comments
 (0)