Nextcloud Circles API

FederatedUserService
in package
Uses TArrayTools, TStringTools, TNCLogger, TDeserialize

Class FederatedUserService

Table of Contents

CACHE_SINGLE_CIRCLE  = 'circles/singleCircle'
CACHE_SINGLE_CIRCLE_TTL  = 900
CONFLICT_001  = 1
CONFLICT_002  = 2
CONFLICT_003  = 3
CONFLICT_004  = 4
CONFLICT_005  = 5
$ALERT  : mixed
$CRITICAL  : mixed
$DEBUG  : mixed
$EMERGENCY  : mixed
$ERROR  : mixed
$INFO  : mixed
$NOTICE  : mixed
$TYPE_ARRAY  : mixed
$TYPE_BOOLEAN  : mixed
$TYPE_INTEGER  : mixed
$TYPE_NULL  : mixed
$TYPE_SERIALIZABLE  : mixed
$TYPE_STRING  : mixed
$WARNING  : mixed
$bypass  : bool
$cache  : ICache
$circleRequest  : CircleRequest
$configService  : ConfigService
$contactService  : ContactService
$currentApp  : FederatedUser
$currentUser  : FederatedUser
$federatedEventService  : FederatedEventService
$groupManager  : IGroupManager
$initiatedByAdmin  : FederatedUser
$initiatedByOcc  : bool
$interfaceService  : InterfaceService
$memberRequest  : MemberRequest
$membershipService  : MembershipService
$remoteInstance  : RemoteInstance
$remoteService  : RemoteService
$remoteStreamService  : RemoteStreamService
$userManager  : IUserManager
$userSession  : IUserSession
__construct()  : mixed
FederatedUserService constructor.
alert()  : void
bypassCurrentUserCondition()  : void
canBypassCurrentUserCondition()  : bool
commandLineInitiator()  : void
some ./occ commands allows to add an Initiator, or force the PoV from the local circles' owner
confirmLocalSingleId()  : void
Confirm that the singleId of a FederatedUser is unique and not used to any other member of the database.
confirmSingleIdUniqueness()  : void
// TODO: implement this check in a maintenance background job
confirmSuperSession()  : void
debug()  : void
deleteFederatedUser()  : void
deserialize()  : IDeserializable
deserializeArray()  : array<string|int, IDeserializable>
deserializeJson()  : IDeserializable
deserializeList()  : array<string|int, IDeserializable>
e()  : void
emergency()  : void
exception()  : void
extractIdAndInstance()  : array<string|int, mixed>
extract userID and instance from a federatedId
generateFederatedUser()  : FederatedUser
Generate a FederatedUser based on local data.
generateRandomSentence()  : string
generateRandomWord()  : string
getAppInitiator()  : FederatedUser
Get the full FederatedUser for a local user.
getCurrentApp()  : FederatedUser|null
getCurrentEntity()  : FederatedUser|null
getCurrentUser()  : FederatedUser|null
getDateDiff()  : string
getFederatedMember()  : Member
Works like getFederatedUser, but returns a member.
getFederatedUser()  : FederatedUser
get a valid FederatedUser, based on the federatedId (userId@instance) and its type.
getFederatedUser_Contact()  : FederatedUser
getFederatedUser_Group()  : FederatedUser
getFederatedUser_Mail()  : FederatedUser
getFederatedUser_SingleId()  : FederatedUser
getGroupCircle()  : Circle
getInitiatedByAdmin()  : FederatedUser
getLocalFederatedUser()  : FederatedUser
Get the full FederatedUser for a local user.
getRemoteInstance()  : RemoteInstance|null
hasCurrentApp()  : bool
hasCurrentEntity()  : bool
hasCurrentUser()  : bool
hasRemoteInstance()  : bool
humanReadable()  : string
initCurrentUser()  : void
specify $defaultUser in case a session is not opened but user needs to be emulated (ie. cron)
isInitiatedByAdmin()  : bool
isInitiatedByOcc()  : bool
log()  : void
logger()  : LoggerInterface
mustHaveCurrentUser()  : void
notice()  : void
serialize()  : array<string|int, mixed>
serializeArray()  : array<string|int, mixed>
setCurrentPatron()  : void
setCurrentUser()  : void
set a CurrentUser, based on a IFederatedUser.
setInitiatedByAdmin()  : void
setInitiatedByOcc()  : void
setLocalCurrentApp()  : void
setLocalCurrentUser()  : void
setLocalCurrentUserId()  : void
setMemberPatron()  : void
setOwnerAsCurrentUser()  : void
setRemoteInstance()  : void
set a RemoteInstance, mostly from a remote request (RemoteController) Used to limit rights in some request in the local database.
t()  : void
throwable()  : void
typeOf()  : string
unsetCurrentUser()  : void
validKey()  : bool
warning()  : void
cleanArray()  : mixed
commonPart()  : string
cut()  : string
extractArray()  : mixed
feedStringWithParams()  : string
get()  : string
getArray()  : array<string|int, mixed>
getBool()  : bool
getFloat()  : float
getInt()  : int
getList()  : array<string|int, mixed>
getObj()  : mixed
isUuid()  : bool
mustContains()  : mixed
token()  : string
uuid()  : string
Generate uuid: 2b5a7a87-8db1-445f-a17b-405790f91c80
cacheSingleCircle()  : void
confirmFederatedUser()  : void
Confirm that all field of a FederatedUser are filled.
fillSingleCircleId()  : void
generateCacheKey()  : string
getCachedSingleCircle()  : Circle
getFederatedUser_User()  : FederatedUser
getSingleCircle()  : Circle
get the Single Circle from a local user
markConflict()  : void

Constants

Properties

$EMERGENCY

public static mixed $EMERGENCY = 4

$TYPE_ARRAY

public static mixed $TYPE_ARRAY = 'Array'

$TYPE_BOOLEAN

public static mixed $TYPE_BOOLEAN = 'Boolean'

$TYPE_INTEGER

public static mixed $TYPE_INTEGER = 'Integer'

$TYPE_SERIALIZABLE

public static mixed $TYPE_SERIALIZABLE = 'Serializable'

$TYPE_STRING

public static mixed $TYPE_STRING = 'String'

Methods

__construct()

FederatedUserService constructor.

public __construct(IUserSession $userSession, IUserManager $userManager, IGroupManager $groupManager, ICacheFactory $cacheFactory, FederatedEventService $federatedEventService, MembershipService $membershipService, CircleRequest $circleRequest, MemberRequest $memberRequest, RemoteService $remoteService, RemoteStreamService $remoteStreamService, ContactService $contactService, InterfaceService $interfaceService, ConfigService $configService) : mixed
Parameters
$userSession : IUserSession
$userManager : IUserManager
$groupManager : IGroupManager
$cacheFactory : ICacheFactory
$federatedEventService : FederatedEventService
$membershipService : MembershipService
$circleRequest : CircleRequest
$memberRequest : MemberRequest
$remoteService : RemoteService
$remoteStreamService : RemoteStreamService
$contactService : ContactService
$interfaceService : InterfaceService
$configService : ConfigService
Return values
mixed —

alert()

public alert(string $message[, bool $trace = false ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$message : string
$trace : bool = false
$serializable : array<string|int, mixed> = []
Return values
void —

bypassCurrentUserCondition()

public bypassCurrentUserCondition(bool $bypass) : void
Parameters
$bypass : bool
Return values
void —

canBypassCurrentUserCondition()

public canBypassCurrentUserCondition() : bool
Return values
bool —

commandLineInitiator()

some ./occ commands allows to add an Initiator, or force the PoV from the local circles' owner

public commandLineInitiator(string $userId[, int $userType = Member::TYPE_SINGLE ][, string $circleId = '' ][, bool $bypass = false ]) : void

TODO: manage non-user type ?

Parameters
$userId : string
$userType : int = Member::TYPE_SINGLE
$circleId : string = ''
$bypass : bool = false
Tags
throws
CircleNotFoundException
throws
FederatedItemException
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
InvalidIdException
throws
MemberNotFoundException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
RequestBuilderException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
UserTypeNotFoundException
Return values
void —

debug()

public debug(string $message[, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$message : string
$serializable : array<string|int, mixed> = []
Return values
void —

deserializeArray()

public deserializeArray(array<string|int, mixed> $data, string $class[, bool $associative = false ]) : array<string|int, IDeserializable>
Parameters
$data : array<string|int, mixed>
$class : string
$associative : bool = false
Return values
array<string|int, IDeserializable> —

e()

public e(Exception $e[, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$e : Exception
$serializable : array<string|int, mixed> = []
Return values
void —

emergency()

public emergency(string $message[, bool $trace = false ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$message : string
$trace : bool = false
$serializable : array<string|int, mixed> = []
Return values
void —

exception()

public exception(Exception $e[, int|array<string|int, mixed> $level = 3 ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$e : Exception
$level : int|array<string|int, mixed> = 3
$serializable : array<string|int, mixed> = []
Return values
void —

extractIdAndInstance()

extract userID and instance from a federatedId

public extractIdAndInstance(string $federatedId) : array<string|int, mixed>
Parameters
$federatedId : string
Return values
array<string|int, mixed> —

generateFederatedUser()

Generate a FederatedUser based on local data.

public generateFederatedUser(string $federatedId, int $type) : FederatedUser

WARNING: There is no confirmation that the returned FederatedUser exists or is valid at this point. Use getFederatedUser() instead if a valid and confirmed FederatedUser is needed.

if $federatedId is a known SingleId, will returns data from the local database. if $federatedId is a local username, will returns data from the local database. Otherwise, the FederatedUser will not contains a SingleId.

Parameters
$federatedId : string
$type : int
Return values
FederatedUser —

generateRandomSentence()

public generateRandomSentence([int $words = 5 ]) : string
Parameters
$words : int = 5
Return values
string —

generateRandomWord()

public generateRandomWord([int $length = 8 ]) : string
Parameters
$length : int = 8
Return values
string —

getAppInitiator()

Get the full FederatedUser for a local user.

public getAppInitiator(string $appId, int $appNumber[, string $appDisplayName = '' ]) : FederatedUser

Will generate the SingleId if none exist

Parameters
$appId : string
$appNumber : int
$appDisplayName : string = ''
Tags
throws
ContactAddressBookNotFoundException
throws
ContactFormatException
throws
ContactNotFoundException
throws
FederatedUserException
throws
InvalidIdException
throws
RequestBuilderException
throws
SingleCircleNotFoundException
Return values
FederatedUser —

getDateDiff()

public getDateDiff(int $first, int $second[, bool $short = false ][, array<string|int, mixed> $words = [] ]) : string
Parameters
$first : int
$second : int
$short : bool = false
$words : array<string|int, mixed> = []
Tags
throws
Exception
Return values
string —

getFederatedMember()

Works like getFederatedUser, but returns a member.

public getFederatedMember(string $userId[, int $level = Member::LEVEL_MEMBER ]) : Member

Allow to specify a level: handle@instance,level

Used for filters when searching for Circles TODO: Used outside of ./occ circles:manage:list ?

Parameters
$userId : string
$level : int = Member::LEVEL_MEMBER
Tags
throws
CircleNotFoundException
throws
FederatedItemException
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
InvalidIdException
throws
MemberNotFoundException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
UserTypeNotFoundException
Return values
Member —

getFederatedUser()

get a valid FederatedUser, based on the federatedId (userId@instance) and its type.

public getFederatedUser(string $federatedId[, int $type = Member::TYPE_SINGLE ]) : FederatedUser

If instance is local, get the local valid FederatedUser If instance is not local, get the remote valid FederatedUser

Parameters
$federatedId : string
$type : int = Member::TYPE_SINGLE
Tags
throws
CircleNotFoundException
throws
FederatedItemException
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
InvalidIdException
throws
MemberNotFoundException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
UserTypeNotFoundException
throws
RequestBuilderException
Return values
FederatedUser —

getFederatedUser_Group()

public getFederatedUser_Group(string $groupName, string $instance) : FederatedUser
Parameters
$groupName : string
$instance : string
Tags
throws
FederatedEventException
throws
FederatedItemException
throws
FederatedUserException
throws
GroupNotFoundException
throws
InitiatorNotConfirmedException
throws
InvalidIdException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
RequestBuilderException
Return values
FederatedUser —

getFederatedUser_SingleId()

public getFederatedUser_SingleId(string $singleId, string $instance) : FederatedUser
Parameters
$singleId : string
$instance : string
Tags
throws
CircleNotFoundException
throws
FederatedItemException
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
MemberNotFoundException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
UnknownRemoteException
throws
RequestBuilderException
Return values
FederatedUser —

getGroupCircle()

public getGroupCircle(string $groupId) : Circle
Parameters
$groupId : string
Tags
throws
GroupNotFoundException
throws
FederatedEventException
throws
FederatedItemException
throws
FederatedUserException
throws
InitiatorNotConfirmedException
throws
InvalidIdException
throws
OwnerNotFoundException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
RequestBuilderException
Return values
Circle —

getLocalFederatedUser()

Get the full FederatedUser for a local user.

public getLocalFederatedUser(string $userId[, bool $check = true ]) : FederatedUser

Will generate the SingleId if none exist

Parameters
$userId : string
$check : bool = true
Tags
throws
ContactAddressBookNotFoundException
throws
ContactFormatException
throws
ContactNotFoundException
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
InvalidIdException
throws
RequestBuilderException
throws
SingleCircleNotFoundException
Return values
FederatedUser —

humanReadable()

public humanReadable(int $bytes) : string
Parameters
$bytes : int
Return values
string —

log()

public log(int $level, string $message[, bool $trace = false ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$level : int
$message : string
$trace : bool = false
$serializable : array<string|int, mixed> = []
Return values
void —

logger()

public logger() : LoggerInterface
Return values
LoggerInterface —

notice()

public notice(string $message[, bool $trace = false ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$message : string
$trace : bool = false
$serializable : array<string|int, mixed> = []
Return values
void —

serialize()

public serialize(JsonSerializable $model) : array<string|int, mixed>
Parameters
$model : JsonSerializable
Return values
array<string|int, mixed> —

serializeArray()

public serializeArray(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
Return values
array<string|int, mixed> —

setInitiatedByOcc()

public setInitiatedByOcc(bool $initiatedByOcc) : void
Parameters
$initiatedByOcc : bool
Return values
void —

setRemoteInstance()

set a RemoteInstance, mostly from a remote request (RemoteController) Used to limit rights in some request in the local database.

public setRemoteInstance(RemoteInstance $remoteInstance) : void
Parameters
$remoteInstance : RemoteInstance
Return values
void —

t()

public t(Throwable $t[, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$t : Throwable
$serializable : array<string|int, mixed> = []
Return values
void —

throwable()

public throwable(Throwable $t[, int $level = 3 ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$t : Throwable
$level : int = 3
$serializable : array<string|int, mixed> = []
Return values
void —

typeOf()

public typeOf(string $key, array<string|int, mixed> $arr[, bool $root = true ]) : string
Parameters
$key : string
$arr : array<string|int, mixed>
$root : bool = true
Tags
throws
ItemNotFoundException
throws
UnknownTypeException
Return values
string —

validKey()

public validKey(string $k, array<string|int, mixed> $arr) : bool
Parameters
$k : string
$arr : array<string|int, mixed>
Return values
bool —

warning()

public warning(string $message[, bool $trace = false ][, array<string|int, mixed> $serializable = [] ]) : void
Parameters
$message : string
$trace : bool = false
$serializable : array<string|int, mixed> = []
Return values
void —

cleanArray()

protected cleanArray(array<string|int, mixed> &$arr) : mixed
Parameters
$arr : array<string|int, mixed>
Return values
mixed —

commonPart()

protected commonPart(string $str1, string $str2[, bool $cs = true ]) : string
Parameters
$str1 : string
$str2 : string
$cs : bool = true

case sensitive ?

Return values
string —

cut()

protected cut(string $line, int $length) : string
Parameters
$line : string
$length : int
Return values
string —

extractArray()

protected extractArray(string $k, string $value, array<string|int, mixed> $list) : mixed
Parameters
$k : string
$value : string
$list : array<string|int, mixed>
Tags
throws
ArrayNotFoundException
Return values
mixed —

feedStringWithParams()

protected feedStringWithParams(string $line, array<string|int, mixed> $params) : string
Parameters
$line : string
$params : array<string|int, mixed>
Return values
string —

get()

protected get(string $k, array<string|int, mixed> $arr[, string $default = '' ]) : string
Parameters
$k : string
$arr : array<string|int, mixed>
$default : string = ''
Return values
string —

getArray()

protected getArray(string $k, array<string|int, mixed> $arr[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
$k : string
$arr : array<string|int, mixed>
$default : array<string|int, mixed> = []
Return values
array<string|int, mixed> —

getBool()

protected getBool(string $k, array<string|int, mixed> $arr[, bool $default = false ]) : bool
Parameters
$k : string
$arr : array<string|int, mixed>
$default : bool = false
Return values
bool —

getFloat()

protected getFloat(string $k, array<string|int, mixed> $arr, float $default) : float
Parameters
$k : string
$arr : array<string|int, mixed>
$default : float
Return values
float —

getInt()

protected getInt(string $k, array<string|int, mixed> $arr, int $default) : int
Parameters
$k : string
$arr : array<string|int, mixed>
$default : int
Return values
int —

getList()

protected getList(string $k, array<string|int, mixed> $arr, array<string|int, mixed> $import[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
$k : string
$arr : array<string|int, mixed>
$import : array<string|int, mixed>
$default : array<string|int, mixed> = []
Return values
array<string|int, mixed> —

getObj()

protected getObj(string $k, array<string|int, mixed> $arr[, JsonSerializable|null $default = null ]) : mixed
Parameters
$k : string
$arr : array<string|int, mixed>
$default : JsonSerializable|null = null
Return values
mixed —

isUuid()

protected isUuid(string $uuid) : bool
Parameters
$uuid : string
Return values
bool —

mustContains()

protected mustContains(array<string|int, mixed> $keys, array<string|int, mixed> $arr) : mixed
Parameters
$keys : array<string|int, mixed>
$arr : array<string|int, mixed>
Tags
throws
MalformedArrayException
Return values
mixed —

token()

protected token([int $length = 15 ]) : string
Parameters
$length : int = 15
Return values
string —

uuid()

Generate uuid: 2b5a7a87-8db1-445f-a17b-405790f91c80

protected uuid(int $length) : string
Parameters
$length : int
Return values
string —

getFederatedUser_User()

private getFederatedUser_User(string $userId, string $instance) : FederatedUser
Parameters
$userId : string
$instance : string
Tags
throws
FederatedUserException
throws
FederatedUserNotFoundException
throws
InvalidIdException
throws
RemoteInstanceException
throws
RemoteNotFoundException
throws
RemoteResourceNotFoundException
throws
SingleCircleNotFoundException
throws
UnknownRemoteException
throws
FederatedItemException
throws
RequestBuilderException
Return values
FederatedUser —

getSingleCircle()

get the Single Circle from a local user

private getSingleCircle(FederatedUser $federatedUser[, bool $generate = true ]) : Circle
Parameters
$federatedUser : FederatedUser
$generate : bool = true
Tags
throws
ContactAddressBookNotFoundException
throws
ContactFormatException
throws
ContactNotFoundException
throws
FederatedUserException
throws
InvalidIdException
throws
RequestBuilderException
throws
SingleCircleNotFoundException
Return values
Circle —

Search results