Skip to content

Commit b40e85c

Browse files
committed
wip
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent 7a4e088 commit b40e85c

File tree

9 files changed

+81
-3
lines changed

9 files changed

+81
-3
lines changed

apps/dav/lib/Connector/Sabre/FilesPlugin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class FilesPlugin extends ServerPlugin {
8181
public const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
8282
public const MOUNT_ROOT_PROPERTYNAME = '{http://nextcloud.org/ns}is-mount-root';
8383
public const IS_ENCRYPTED_PROPERTYNAME = '{http://nextcloud.org/ns}is-encrypted';
84+
public const IS_FEDERATED_PROPERTYNAME = '{http://nextcloud.org/ns}is-federated';
8485
public const METADATA_ETAG_PROPERTYNAME = '{http://nextcloud.org/ns}metadata_etag';
8586
public const UPLOAD_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}upload_time';
8687
public const CREATION_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}creation_time';
@@ -149,6 +150,7 @@ public function initialize(Server $server) {
149150
$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
150151
$server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME;
151152
$server->protectedProperties[] = self::IS_ENCRYPTED_PROPERTYNAME;
153+
$server->protectedProperties[] = self::IS_FEDERATED_PROPERTYNAME;
152154
$server->protectedProperties[] = self::SHARE_NOTE;
153155

154156
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
@@ -413,6 +415,10 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
413415
$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
414416
return $node->getName();
415417
});
418+
419+
$propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function () use ($node) {
420+
return $node->getOwner()->isFederated();
421+
});
416422
}
417423

418424
if ($node instanceof \OCA\DAV\Connector\Sabre\File) {

apps/files/src/components/VirtualList.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ export default Vue.extend({
168168
}
169169
170170
const items = this.dataSources.slice(this.startIndex, this.startIndex + this.shownItems) as Node[]
171+
console.log("Items list", items)
171172
172173
const oldItems = items.filter(item => Object.values(this.$_recycledPool).includes(item[this.dataKey]))
173174
const oldItemsKeys = oldItems.map(item => item[this.dataKey] as string)
174175
const unusedKeys = Object.keys(this.$_recycledPool).filter(key => !oldItemsKeys.includes(this.$_recycledPool[key]))
176+
console.log("Unused keys", unusedKeys)
175177
176178
return items.map(item => {
177179
const index = Object.values(this.$_recycledPool).indexOf(item[this.dataKey])

apps/files_sharing/src/actions/sharingStatusAction.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ import { generateAvatarSvg } from '../utils/AccountIcon.ts'
3434

3535
import './sharingStatusAction.scss'
3636

37+
<<<<<<< Updated upstream
38+
=======
39+
const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches === true
40+
|| document.querySelector('[data-themes*=dark]') !== null
41+
42+
const generateAvatarSvg = (userId: string, isGuest = false) => {
43+
console.debug("USER ID, is Guest", userId, isGuest)
44+
const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
45+
const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId })
46+
return `<svg width="32" height="32" viewBox="0 0 32 32"
47+
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
48+
<image href="${avatarUrl}" height="32" width="32" />
49+
</svg>`
50+
}
51+
52+
>>>>>>> Stashed changes
3753
const isExternal = (node: Node) => {
3854
return node.attributes.remote_id !== undefined
3955
}
@@ -100,7 +116,9 @@ export const action = new FileAction({
100116

101117
const ownerId = node?.attributes?.['owner-id']
102118
if (ownerId && (ownerId !== getCurrentUser()?.uid || isExternal(node))) {
103-
return generateAvatarSvg(ownerId, isExternal(node))
119+
console.debug("IS EXTERNAL", isExternal(node))
120+
console.debug("EXTENAL NODE", node)
121+
return generateAvatarSvg(ownerId, true)
104122
}
105123

106124
return AccountPlusSvg

apps/files_sharing/src/services/SharingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
8585

8686
let mtime = ocsEntry.item_mtime ? new Date((ocsEntry.item_mtime) * 1000) : undefined
8787
// Prefer share time if more recent than item mtime
88-
if (ocsEntry?.stime > (ocsEntry?.item_mtime || 0)) {
88+
if (ocsEntry?.stime > (ocsEntry?.item_mtime || 0)) {ocsEntryToNode
8989
mtime = new Date((ocsEntry.stime) * 1000)
9090
}
9191

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,21 @@ export default {
880880
}
881881
882882
await this.getNode()
883+
console.log("Newly fetched", this.node)
883884
emit('files:node:updated', this.node)
884885
886+
<<<<<<< Updated upstream
887+
=======
888+
if (this.$refs.externalLinkActions?.length > 0) {
889+
await Promise.allSettled(this.$rethis.nodefs.externalLinkActions.map((action) => {
890+
if (typeof action.$children.at(0)?.onSave !== 'function') {
891+
return Promise.resolve()
892+
}
893+
return action.$children.at(0)?.onSave?.()
894+
}))
895+
}
896+
897+
>>>>>>> Stashed changes
885898
this.$emit('close-sharing-details')
886899
},
887900
/**

core/src/files/client.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import escapeHTML from 'escape-html'
103103
Client.PROPERTY_SIZE = '{' + Client.NS_OWNCLOUD + '}size'
104104
Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength'
105105
Client.PROPERTY_ISENCRYPTED = '{' + Client.NS_DAV + '}is-encrypted'
106+
Client.PROPERTY_ISFEDERATED = '{' + Client.NS_DAV + '}is-federated'
106107
Client.PROPERTY_SHARE_PERMISSIONS = '{' + Client.NS_OCS + '}share-permissions'
107108
Client.PROPERTY_SHARE_ATTRIBUTES = '{' + Client.NS_NEXTCLOUD + '}share-attributes'
108109
Client.PROPERTY_QUOTA_AVAILABLE_BYTES = '{' + Client.NS_DAV + '}quota-available-bytes'
@@ -157,6 +158,10 @@ import escapeHTML from 'escape-html'
157158
* Encryption state
158159
*/
159160
[Client.NS_NEXTCLOUD, 'is-encrypted'],
161+
/**
162+
* Federation state
163+
*/
164+
[Client.NS_NEXTCLOUD, 'is-federated'],
160165
/**
161166
* Share permissions
162167
*/
@@ -303,7 +308,7 @@ import escapeHTML from 'escape-html'
303308
*
304309
* @returns {Array.<FileInfo>} array of file info
305310
*/
306-
_parseFileInfo: function(response) {
311+
_parseFileInfo: function(response) {Encrypted
307312
let path = decodeURIComponent(response.href)
308313
if (path.substr(0, this._root.length) === this._root) {
309314
path = path.substr(this._root.length)
@@ -355,6 +360,13 @@ import escapeHTML from 'escape-html'
355360
data.isEncrypted = false
356361
}
357362

363+
const isFederatedProp = props['{' + Client.NS_NEXTCLOUD + '}is-federated']
364+
if (!_.isUndefined(isFederatedProp)) {
365+
data.isFederated = isFederatedProp === '1'
366+
} else {
367+
data.isFederated = false
368+
}
369+
358370
const isFavouritedProp = props['{' + Client.NS_OWNCLOUD + '}favorite']
359371
if (!_.isUndefined(isFavouritedProp)) {
360372
data.isFavourited = isFavouritedProp === '1'

lib/private/User/LazyUser.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ private function getUser(): IUser {
5151
$this->user = $this->userManager->get($this->uid);
5252
}
5353
}
54+
55+
if($this->user === null) {
56+
throw new \Exception('User not found');
57+
}
58+
5459
/** @var IUser */
5560
$user = $this->user;
5661
return $user;
@@ -167,4 +172,13 @@ public function getManagerUids(): array {
167172
public function setManagerUids(array $uids): void {
168173
$this->getUser()->setManagerUids($uids);
169174
}
175+
176+
public function isFederated(): bool {
177+
try {
178+
$this->getUser();
179+
return true;
180+
} catch (\Exception $e) {
181+
return false;
182+
}
183+
}
170184
}

lib/private/User/User.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,9 @@ public function triggerChange($feature, $value = null, $oldValue = null) {
618618
$this->emitter->emit('\OC\User', 'changeUser', [$this, $feature, $value, $oldValue]);
619619
}
620620
}
621+
622+
public function isFederated(): bool {
623+
// Federated users only use LazyUser
624+
return false;
625+
}
621626
}

lib/public/IUser.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,12 @@ public function getManagerUids(): array;
287287
* @since 27.0.0
288288
*/
289289
public function setManagerUids(array $uids): void;
290+
291+
/**
292+
* Check if the user is federated (from another server)
293+
*
294+
* @return boll
295+
* @since 28.0.11
296+
*/
297+
public function isFederated(): bool;
290298
}

0 commit comments

Comments
 (0)