@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
60 lines (59 loc) • 1.83 kB
JavaScript
/*
* Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com>
* This file is part of Sync-in | The open source file sync and share solution
* See the LICENSE file for licensing details
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SpaceProps", {
enumerable: true,
get: function() {
return SpaceProps;
}
});
const _functions = require("../../../common/functions");
const _member = require("../../users/constants/member");
const _spaces = require("../constants/spaces");
let SpaceProps = class SpaceProps {
setCounts(userId) {
this.counts = {
users: 0,
groups: 0,
links: 0,
roots: 0,
shares: 0
};
for (const m of this.members){
if (m.type === _member.MEMBER_TYPE.USER || m.type === _member.MEMBER_TYPE.GUEST) {
if (m.linkId) {
this.counts.links++;
} else {
this.counts.users++;
}
} else {
this.counts.groups++;
}
}
for (const r of this.roots){
if (r.owner?.id === userId) {
this.counts.roots++;
}
}
}
constructor(props, userId){
// Extra properties
this.members = [];
this.roots = [];
if (props?.role === _spaces.SPACE_ROLE.IS_MANAGER) {
props.permissions = _spaces.SPACE_ALL_OPERATIONS;
} else if (props.permissions) {
props.permissions = (0, _functions.uniquePermissions)(props.permissions);
}
Object.assign(this, props);
if (userId) {
this.setCounts(userId);
}
}
};
//# sourceMappingURL=space-props.model.js.map