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

[master] WIP : 44287 fix avatar fed share receiver #48167

Closed
wants to merge 1 commit into from
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
4 changes: 4 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
return $node->getName();
});

$propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function () use ($node) {
return $node->getOwner()->isFederated();
});
}

if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
Expand Down
2 changes: 2 additions & 0 deletions apps/files/src/components/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ export default Vue.extend({
}

const items = this.dataSources.slice(this.startIndex, this.startIndex + this.shownItems) as Node[]
console.log("Items list", items)

const oldItems = items.filter(item => Object.values(this.$_recycledPool).includes(item[this.dataKey]))
const oldItemsKeys = oldItems.map(item => item[this.dataKey] as string)
const unusedKeys = Object.keys(this.$_recycledPool).filter(key => !oldItemsKeys.includes(this.$_recycledPool[key]))
console.log("Unused keys", unusedKeys)

return items.map(item => {
const index = Object.values(this.$_recycledPool).indexOf(item[this.dataKey])
Expand Down
16 changes: 16 additions & 0 deletions apps/files_sharing/src/files_actions/sharingStatusAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ import { generateAvatarSvg } from '../utils/AccountIcon'

import './sharingStatusAction.scss'

<<<<<<< Updated upstream
=======
const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches === true
|| document.querySelector('[data-themes*=dark]') !== null

const generateAvatarSvg = (userId: string, isGuest = false) => {
console.debug("USER ID, is Guest", userId, isGuest)
const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId })
return `<svg width="32" height="32" viewBox="0 0 32 32"
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
<image href="${avatarUrl}" height="32" width="32" />
</svg>`
}

>>>>>>> Stashed changes
const isExternal = (node: Node) => {
return node.attributes.remote_id !== undefined
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/src/services/SharingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu

let mtime = ocsEntry.item_mtime ? new Date((ocsEntry.item_mtime) * 1000) : undefined
// Prefer share time if more recent than item mtime
if (ocsEntry?.stime > (ocsEntry?.item_mtime || 0)) {
if (ocsEntry?.stime > (ocsEntry?.item_mtime || 0)) {ocsEntryToNode
mtime = new Date((ocsEntry.stime) * 1000)
}

Expand Down
1 change: 1 addition & 0 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ export default {
}

await this.getNode()
console.log("Newly fetched", this.node)
emit('files:node:updated', this.node)

if (this.$refs.externalLinkActions?.length > 0) {
Expand Down
14 changes: 13 additions & 1 deletion core/src/files/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import escapeHTML from 'escape-html'
Client.PROPERTY_SIZE = '{' + Client.NS_OWNCLOUD + '}size'
Client.PROPERTY_GETCONTENTLENGTH = '{' + Client.NS_DAV + '}getcontentlength'
Client.PROPERTY_ISENCRYPTED = '{' + Client.NS_DAV + '}is-encrypted'
Client.PROPERTY_ISFEDERATED = '{' + Client.NS_DAV + '}is-federated'
Client.PROPERTY_SHARE_PERMISSIONS = '{' + Client.NS_OCS + '}share-permissions'
Client.PROPERTY_SHARE_ATTRIBUTES = '{' + Client.NS_NEXTCLOUD + '}share-attributes'
Client.PROPERTY_QUOTA_AVAILABLE_BYTES = '{' + Client.NS_DAV + '}quota-available-bytes'
Expand Down Expand Up @@ -131,6 +132,10 @@ import escapeHTML from 'escape-html'
* Encryption state
*/
[Client.NS_NEXTCLOUD, 'is-encrypted'],
/**
* Federation state
*/
[Client.NS_NEXTCLOUD, 'is-federated'],
/**
* Share permissions
*/
Expand Down Expand Up @@ -277,7 +282,7 @@ import escapeHTML from 'escape-html'
*
* @returns {Array.<FileInfo>} array of file info
*/
_parseFileInfo: function(response) {
_parseFileInfo: function(response) {Encrypted
let path = decodeURIComponent(response.href)
if (path.substr(0, this._root.length) === this._root) {
path = path.substr(this._root.length)
Expand Down Expand Up @@ -329,6 +334,13 @@ import escapeHTML from 'escape-html'
data.isEncrypted = false
}

const isFederatedProp = props['{' + Client.NS_NEXTCLOUD + '}is-federated']
if (!_.isUndefined(isFederatedProp)) {
data.isFederated = isFederatedProp === '1'
} else {
data.isFederated = false
}

const isFavouritedProp = props['{' + Client.NS_OWNCLOUD + '}favorite']
if (!_.isUndefined(isFavouritedProp)) {
data.isFavourited = isFavouritedProp === '1'
Expand Down
14 changes: 14 additions & 0 deletions lib/private/User/LazyUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ private function getUser(): IUser {
$this->user = $this->userManager->get($this->uid);
}
}

if($this->user === null) {
throw new \Exception('User not found');
}

/** @var IUser */
$user = $this->user;
return $user;
Expand Down Expand Up @@ -160,4 +165,13 @@ public function getManagerUids(): array {
public function setManagerUids(array $uids): void {
$this->getUser()->setManagerUids($uids);
}

public function isFederated(): bool {
try {
$this->getUser();
return true;
} catch (\Exception $e) {
return false;
}
}
}
5 changes: 5 additions & 0 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,9 @@ public function triggerChange($feature, $value = null, $oldValue = null) {
$this->emitter->emit('\OC\User', 'changeUser', [$this, $feature, $value, $oldValue]);
}
}

public function isFederated(): bool {
// Federated users only use LazyUser
return false;
}
}
8 changes: 8 additions & 0 deletions lib/public/IUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,12 @@ public function getManagerUids(): array;
* @since 27.0.0
*/
public function setManagerUids(array $uids): void;

/**
* Check if the user is federated (from another server)
*
* @return boll
* @since 28.0.11
*/
public function isFederated(): bool;
}