@@ -61,5 +61,5 @@ |
||
| 61 | 61 | * @return string|null - The value stored for the key, null if no value stored |
| 62 | 62 | * @since 17.0.0 |
| 63 | 63 | */ |
| 64 | - public function getMetadataForKey(string $key):?string; |
|
| 64 | + public function getMetadataForKey(string $key): ?string; |
|
| 65 | 65 | } |
@@ -30,33 +30,33 @@ |
||
| 30 | 30 | * @since 17.0.0 |
| 31 | 31 | */ |
| 32 | 32 | interface IMetadataProvider { |
| 33 | - /** |
|
| 34 | - * Get a list of all metadata keys available for this room |
|
| 35 | - * |
|
| 36 | - * Room backends are allowed to return custom keys, beyond the ones |
|
| 37 | - * defined in this class. If they do, they should make sure to use their |
|
| 38 | - * own namespace. |
|
| 39 | - * |
|
| 40 | - * @return String[] - A list of available keys |
|
| 41 | - * @since 17.0.0 |
|
| 42 | - */ |
|
| 43 | - public function getAllAvailableMetadataKeys():array; |
|
| 33 | + /** |
|
| 34 | + * Get a list of all metadata keys available for this room |
|
| 35 | + * |
|
| 36 | + * Room backends are allowed to return custom keys, beyond the ones |
|
| 37 | + * defined in this class. If they do, they should make sure to use their |
|
| 38 | + * own namespace. |
|
| 39 | + * |
|
| 40 | + * @return String[] - A list of available keys |
|
| 41 | + * @since 17.0.0 |
|
| 42 | + */ |
|
| 43 | + public function getAllAvailableMetadataKeys():array; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get whether or not a metadata key is set for this room |
|
| 47 | - * |
|
| 48 | - * @param string $key - The key to check for |
|
| 49 | - * @return bool - Whether or not key is available |
|
| 50 | - * @since 17.0.0 |
|
| 51 | - */ |
|
| 52 | - public function hasMetadataForKey(string $key):bool; |
|
| 45 | + /** |
|
| 46 | + * Get whether or not a metadata key is set for this room |
|
| 47 | + * |
|
| 48 | + * @param string $key - The key to check for |
|
| 49 | + * @return bool - Whether or not key is available |
|
| 50 | + * @since 17.0.0 |
|
| 51 | + */ |
|
| 52 | + public function hasMetadataForKey(string $key):bool; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get the value for a metadata key |
|
| 56 | - * |
|
| 57 | - * @param string $key - The key to check for |
|
| 58 | - * @return string|null - The value stored for the key, null if no value stored |
|
| 59 | - * @since 17.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getMetadataForKey(string $key):?string; |
|
| 54 | + /** |
|
| 55 | + * Get the value for a metadata key |
|
| 56 | + * |
|
| 57 | + * @param string $key - The key to check for |
|
| 58 | + * @return string|null - The value stored for the key, null if no value stored |
|
| 59 | + * @since 17.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getMetadataForKey(string $key):?string; |
|
| 62 | 62 | } |
@@ -60,10 +60,10 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public function mergePolicies(FeaturePolicy $defaultPolicy, |
| 62 | 62 | EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
| 63 | - foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 64 | - $setter = 'set' . ucfirst($name); |
|
| 63 | + foreach ((object) (array) $originalPolicy as $name => $value) { |
|
| 64 | + $setter = 'set'.ucfirst($name); |
|
| 65 | 65 | if (\is_array($value)) { |
| 66 | - $getter = 'get' . ucfirst($name); |
|
| 66 | + $getter = 'get'.ucfirst($name); |
|
| 67 | 67 | $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
| 68 | 68 | $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
| 69 | 69 | } elseif (\is_bool($value)) { |
@@ -31,48 +31,48 @@ |
||
| 31 | 31 | use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; |
| 32 | 32 | |
| 33 | 33 | class FeaturePolicyManager { |
| 34 | - /** @var EmptyFeaturePolicy[] */ |
|
| 35 | - private $policies = []; |
|
| 34 | + /** @var EmptyFeaturePolicy[] */ |
|
| 35 | + private $policies = []; |
|
| 36 | 36 | |
| 37 | - /** @var IEventDispatcher */ |
|
| 38 | - private $dispatcher; |
|
| 37 | + /** @var IEventDispatcher */ |
|
| 38 | + private $dispatcher; |
|
| 39 | 39 | |
| 40 | - public function __construct(IEventDispatcher $dispatcher) { |
|
| 41 | - $this->dispatcher = $dispatcher; |
|
| 42 | - } |
|
| 40 | + public function __construct(IEventDispatcher $dispatcher) { |
|
| 41 | + $this->dispatcher = $dispatcher; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function addDefaultPolicy(EmptyFeaturePolicy $policy): void { |
|
| 45 | - $this->policies[] = $policy; |
|
| 46 | - } |
|
| 44 | + public function addDefaultPolicy(EmptyFeaturePolicy $policy): void { |
|
| 45 | + $this->policies[] = $policy; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function getDefaultPolicy(): FeaturePolicy { |
|
| 49 | - $event = new AddFeaturePolicyEvent($this); |
|
| 50 | - $this->dispatcher->dispatchTyped($event); |
|
| 48 | + public function getDefaultPolicy(): FeaturePolicy { |
|
| 49 | + $event = new AddFeaturePolicyEvent($this); |
|
| 50 | + $this->dispatcher->dispatchTyped($event); |
|
| 51 | 51 | |
| 52 | - $defaultPolicy = new FeaturePolicy(); |
|
| 53 | - foreach ($this->policies as $policy) { |
|
| 54 | - $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
|
| 55 | - } |
|
| 56 | - return $defaultPolicy; |
|
| 57 | - } |
|
| 52 | + $defaultPolicy = new FeaturePolicy(); |
|
| 53 | + foreach ($this->policies as $policy) { |
|
| 54 | + $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
|
| 55 | + } |
|
| 56 | + return $defaultPolicy; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Merges the first given policy with the second one |
|
| 61 | - * |
|
| 62 | - */ |
|
| 63 | - public function mergePolicies(FeaturePolicy $defaultPolicy, |
|
| 64 | - EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
|
| 65 | - foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 66 | - $setter = 'set' . ucfirst($name); |
|
| 67 | - if (\is_array($value)) { |
|
| 68 | - $getter = 'get' . ucfirst($name); |
|
| 69 | - $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
|
| 70 | - $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
|
| 71 | - } elseif (\is_bool($value)) { |
|
| 72 | - $defaultPolicy->$setter($value); |
|
| 73 | - } |
|
| 74 | - } |
|
| 59 | + /** |
|
| 60 | + * Merges the first given policy with the second one |
|
| 61 | + * |
|
| 62 | + */ |
|
| 63 | + public function mergePolicies(FeaturePolicy $defaultPolicy, |
|
| 64 | + EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
|
| 65 | + foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 66 | + $setter = 'set' . ucfirst($name); |
|
| 67 | + if (\is_array($value)) { |
|
| 68 | + $getter = 'get' . ucfirst($name); |
|
| 69 | + $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
|
| 70 | + $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
|
| 71 | + } elseif (\is_bool($value)) { |
|
| 72 | + $defaultPolicy->$setter($value); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return $defaultPolicy; |
|
| 77 | - } |
|
| 76 | + return $defaultPolicy; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -139,42 +139,42 @@ |
||
| 139 | 139 | if (empty($this->autoplayDomains)) { |
| 140 | 140 | $policy .= "autoplay 'none';"; |
| 141 | 141 | } else { |
| 142 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | + $policy .= 'autoplay '.implode(' ', $this->autoplayDomains); |
|
| 143 | 143 | $policy .= ';'; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (empty($this->cameraDomains)) { |
| 147 | 147 | $policy .= "camera 'none';"; |
| 148 | 148 | } else { |
| 149 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | + $policy .= 'camera '.implode(' ', $this->cameraDomains); |
|
| 150 | 150 | $policy .= ';'; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if (empty($this->fullscreenDomains)) { |
| 154 | 154 | $policy .= "fullscreen 'none';"; |
| 155 | 155 | } else { |
| 156 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | + $policy .= 'fullscreen '.implode(' ', $this->fullscreenDomains); |
|
| 157 | 157 | $policy .= ';'; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (empty($this->geolocationDomains)) { |
| 161 | 161 | $policy .= "geolocation 'none';"; |
| 162 | 162 | } else { |
| 163 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | + $policy .= 'geolocation '.implode(' ', $this->geolocationDomains); |
|
| 164 | 164 | $policy .= ';'; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (empty($this->microphoneDomains)) { |
| 168 | 168 | $policy .= "microphone 'none';"; |
| 169 | 169 | } else { |
| 170 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | + $policy .= 'microphone '.implode(' ', $this->microphoneDomains); |
|
| 171 | 171 | $policy .= ';'; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | if (empty($this->paymentDomains)) { |
| 175 | 175 | $policy .= "payment 'none';"; |
| 176 | 176 | } else { |
| 177 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | + $policy .= 'payment '.implode(' ', $this->paymentDomains); |
|
| 178 | 178 | $policy .= ';'; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -36,147 +36,147 @@ |
||
| 36 | 36 | * @since 17.0.0 |
| 37 | 37 | */ |
| 38 | 38 | class EmptyFeaturePolicy { |
| 39 | - /** @var string[] of allowed domains to autoplay media */ |
|
| 40 | - protected $autoplayDomains = null; |
|
| 41 | - |
|
| 42 | - /** @var string[] of allowed domains that can access the camera */ |
|
| 43 | - protected $cameraDomains = null; |
|
| 44 | - |
|
| 45 | - /** @var string[] of allowed domains that can use fullscreen */ |
|
| 46 | - protected $fullscreenDomains = null; |
|
| 47 | - |
|
| 48 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 49 | - protected $geolocationDomains = null; |
|
| 50 | - |
|
| 51 | - /** @var string[] of allowed domains that can use the microphone */ |
|
| 52 | - protected $microphoneDomains = null; |
|
| 53 | - |
|
| 54 | - /** @var string[] of allowed domains that can use the payment API */ |
|
| 55 | - protected $paymentDomains = null; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
| 59 | - * |
|
| 60 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 61 | - * @return $this |
|
| 62 | - * @since 17.0.0 |
|
| 63 | - */ |
|
| 64 | - public function addAllowedAutoplayDomain(string $domain): self { |
|
| 65 | - $this->autoplayDomains[] = $domain; |
|
| 66 | - return $this; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
| 71 | - * |
|
| 72 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 73 | - * @return $this |
|
| 74 | - * @since 17.0.0 |
|
| 75 | - */ |
|
| 76 | - public function addAllowedCameraDomain(string $domain): self { |
|
| 77 | - $this->cameraDomains[] = $domain; |
|
| 78 | - return $this; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
| 83 | - * |
|
| 84 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 85 | - * @return $this |
|
| 86 | - * @since 17.0.0 |
|
| 87 | - */ |
|
| 88 | - public function addAllowedFullScreenDomain(string $domain): self { |
|
| 89 | - $this->fullscreenDomains[] = $domain; |
|
| 90 | - return $this; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
| 95 | - * |
|
| 96 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 97 | - * @return $this |
|
| 98 | - * @since 17.0.0 |
|
| 99 | - */ |
|
| 100 | - public function addAllowedGeoLocationDomain(string $domain): self { |
|
| 101 | - $this->geolocationDomains[] = $domain; |
|
| 102 | - return $this; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
| 107 | - * |
|
| 108 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 109 | - * @return $this |
|
| 110 | - * @since 17.0.0 |
|
| 111 | - */ |
|
| 112 | - public function addAllowedMicrophoneDomain(string $domain): self { |
|
| 113 | - $this->microphoneDomains[] = $domain; |
|
| 114 | - return $this; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
| 119 | - * |
|
| 120 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 121 | - * @return $this |
|
| 122 | - * @since 17.0.0 |
|
| 123 | - */ |
|
| 124 | - public function addAllowedPaymentDomain(string $domain): self { |
|
| 125 | - $this->paymentDomains[] = $domain; |
|
| 126 | - return $this; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Get the generated Feature-Policy as a string |
|
| 131 | - * |
|
| 132 | - * @return string |
|
| 133 | - * @since 17.0.0 |
|
| 134 | - */ |
|
| 135 | - public function buildPolicy(): string { |
|
| 136 | - $policy = ''; |
|
| 137 | - |
|
| 138 | - if (empty($this->autoplayDomains)) { |
|
| 139 | - $policy .= "autoplay 'none';"; |
|
| 140 | - } else { |
|
| 141 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | - $policy .= ';'; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (empty($this->cameraDomains)) { |
|
| 146 | - $policy .= "camera 'none';"; |
|
| 147 | - } else { |
|
| 148 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | - $policy .= ';'; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (empty($this->fullscreenDomains)) { |
|
| 153 | - $policy .= "fullscreen 'none';"; |
|
| 154 | - } else { |
|
| 155 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | - $policy .= ';'; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (empty($this->geolocationDomains)) { |
|
| 160 | - $policy .= "geolocation 'none';"; |
|
| 161 | - } else { |
|
| 162 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | - $policy .= ';'; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if (empty($this->microphoneDomains)) { |
|
| 167 | - $policy .= "microphone 'none';"; |
|
| 168 | - } else { |
|
| 169 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | - $policy .= ';'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if (empty($this->paymentDomains)) { |
|
| 174 | - $policy .= "payment 'none';"; |
|
| 175 | - } else { |
|
| 176 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | - $policy .= ';'; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return rtrim($policy, ';'); |
|
| 181 | - } |
|
| 39 | + /** @var string[] of allowed domains to autoplay media */ |
|
| 40 | + protected $autoplayDomains = null; |
|
| 41 | + |
|
| 42 | + /** @var string[] of allowed domains that can access the camera */ |
|
| 43 | + protected $cameraDomains = null; |
|
| 44 | + |
|
| 45 | + /** @var string[] of allowed domains that can use fullscreen */ |
|
| 46 | + protected $fullscreenDomains = null; |
|
| 47 | + |
|
| 48 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 49 | + protected $geolocationDomains = null; |
|
| 50 | + |
|
| 51 | + /** @var string[] of allowed domains that can use the microphone */ |
|
| 52 | + protected $microphoneDomains = null; |
|
| 53 | + |
|
| 54 | + /** @var string[] of allowed domains that can use the payment API */ |
|
| 55 | + protected $paymentDomains = null; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
| 59 | + * |
|
| 60 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 61 | + * @return $this |
|
| 62 | + * @since 17.0.0 |
|
| 63 | + */ |
|
| 64 | + public function addAllowedAutoplayDomain(string $domain): self { |
|
| 65 | + $this->autoplayDomains[] = $domain; |
|
| 66 | + return $this; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
| 71 | + * |
|
| 72 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 73 | + * @return $this |
|
| 74 | + * @since 17.0.0 |
|
| 75 | + */ |
|
| 76 | + public function addAllowedCameraDomain(string $domain): self { |
|
| 77 | + $this->cameraDomains[] = $domain; |
|
| 78 | + return $this; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
| 83 | + * |
|
| 84 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 85 | + * @return $this |
|
| 86 | + * @since 17.0.0 |
|
| 87 | + */ |
|
| 88 | + public function addAllowedFullScreenDomain(string $domain): self { |
|
| 89 | + $this->fullscreenDomains[] = $domain; |
|
| 90 | + return $this; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
| 95 | + * |
|
| 96 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 97 | + * @return $this |
|
| 98 | + * @since 17.0.0 |
|
| 99 | + */ |
|
| 100 | + public function addAllowedGeoLocationDomain(string $domain): self { |
|
| 101 | + $this->geolocationDomains[] = $domain; |
|
| 102 | + return $this; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
| 107 | + * |
|
| 108 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 109 | + * @return $this |
|
| 110 | + * @since 17.0.0 |
|
| 111 | + */ |
|
| 112 | + public function addAllowedMicrophoneDomain(string $domain): self { |
|
| 113 | + $this->microphoneDomains[] = $domain; |
|
| 114 | + return $this; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
| 119 | + * |
|
| 120 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 121 | + * @return $this |
|
| 122 | + * @since 17.0.0 |
|
| 123 | + */ |
|
| 124 | + public function addAllowedPaymentDomain(string $domain): self { |
|
| 125 | + $this->paymentDomains[] = $domain; |
|
| 126 | + return $this; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Get the generated Feature-Policy as a string |
|
| 131 | + * |
|
| 132 | + * @return string |
|
| 133 | + * @since 17.0.0 |
|
| 134 | + */ |
|
| 135 | + public function buildPolicy(): string { |
|
| 136 | + $policy = ''; |
|
| 137 | + |
|
| 138 | + if (empty($this->autoplayDomains)) { |
|
| 139 | + $policy .= "autoplay 'none';"; |
|
| 140 | + } else { |
|
| 141 | + $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | + $policy .= ';'; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (empty($this->cameraDomains)) { |
|
| 146 | + $policy .= "camera 'none';"; |
|
| 147 | + } else { |
|
| 148 | + $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | + $policy .= ';'; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (empty($this->fullscreenDomains)) { |
|
| 153 | + $policy .= "fullscreen 'none';"; |
|
| 154 | + } else { |
|
| 155 | + $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | + $policy .= ';'; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (empty($this->geolocationDomains)) { |
|
| 160 | + $policy .= "geolocation 'none';"; |
|
| 161 | + } else { |
|
| 162 | + $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | + $policy .= ';'; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if (empty($this->microphoneDomains)) { |
|
| 167 | + $policy .= "microphone 'none';"; |
|
| 168 | + } else { |
|
| 169 | + $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | + $policy .= ';'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if (empty($this->paymentDomains)) { |
|
| 174 | + $policy .= "payment 'none';"; |
|
| 175 | + } else { |
|
| 176 | + $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | + $policy .= ';'; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return rtrim($policy, ';'); |
|
| 181 | + } |
|
| 182 | 182 | } |
@@ -37,23 +37,23 @@ |
||
| 37 | 37 | * @since 17.0.0 |
| 38 | 38 | */ |
| 39 | 39 | class FeaturePolicy extends EmptyFeaturePolicy { |
| 40 | - protected $autoplayDomains = [ |
|
| 41 | - '\'self\'', |
|
| 42 | - ]; |
|
| 40 | + protected $autoplayDomains = [ |
|
| 41 | + '\'self\'', |
|
| 42 | + ]; |
|
| 43 | 43 | |
| 44 | - /** @var string[] of allowed domains that can access the camera */ |
|
| 45 | - protected $cameraDomains = []; |
|
| 44 | + /** @var string[] of allowed domains that can access the camera */ |
|
| 45 | + protected $cameraDomains = []; |
|
| 46 | 46 | |
| 47 | - protected $fullscreenDomains = [ |
|
| 48 | - '\'self\'', |
|
| 49 | - ]; |
|
| 47 | + protected $fullscreenDomains = [ |
|
| 48 | + '\'self\'', |
|
| 49 | + ]; |
|
| 50 | 50 | |
| 51 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 52 | - protected $geolocationDomains = []; |
|
| 51 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 52 | + protected $geolocationDomains = []; |
|
| 53 | 53 | |
| 54 | - /** @var string[] of allowed domains that can use the microphone */ |
|
| 55 | - protected $microphoneDomains = []; |
|
| 54 | + /** @var string[] of allowed domains that can use the microphone */ |
|
| 55 | + protected $microphoneDomains = []; |
|
| 56 | 56 | |
| 57 | - /** @var string[] of allowed domains that can use the payment API */ |
|
| 58 | - protected $paymentDomains = []; |
|
| 57 | + /** @var string[] of allowed domains that can use the payment API */ |
|
| 58 | + protected $paymentDomains = []; |
|
| 59 | 59 | } |
@@ -36,16 +36,16 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class Proxy extends Entity { |
| 38 | 38 | |
| 39 | - /** @var string */ |
|
| 40 | - protected $ownerId; |
|
| 41 | - /** @var string */ |
|
| 42 | - protected $proxyId; |
|
| 43 | - /** @var int */ |
|
| 44 | - protected $permissions; |
|
| 39 | + /** @var string */ |
|
| 40 | + protected $ownerId; |
|
| 41 | + /** @var string */ |
|
| 42 | + protected $proxyId; |
|
| 43 | + /** @var int */ |
|
| 44 | + protected $permissions; |
|
| 45 | 45 | |
| 46 | - public function __construct() { |
|
| 47 | - $this->addType('ownerId', 'string'); |
|
| 48 | - $this->addType('proxyId', 'string'); |
|
| 49 | - $this->addType('permissions', 'int'); |
|
| 50 | - } |
|
| 46 | + public function __construct() { |
|
| 47 | + $this->addType('ownerId', 'string'); |
|
| 48 | + $this->addType('proxyId', 'string'); |
|
| 49 | + $this->addType('permissions', 'int'); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function changeSchema(IOutput $output, |
| 44 | 44 | \Closure $schemaClosure, |
| 45 | - array $options):?ISchemaWrapper { |
|
| 45 | + array $options): ?ISchemaWrapper { |
|
| 46 | 46 | /** @var ISchemaWrapper $schema */ |
| 47 | 47 | $schema = $schemaClosure(); |
| 48 | 48 | |
@@ -38,86 +38,86 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | class Version1012Date20190808122342 extends SimpleMigrationStep { |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param IOutput $output |
|
| 43 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | - * @param array $options |
|
| 45 | - * @return null|ISchemaWrapper |
|
| 46 | - * @since 17.0.0 |
|
| 47 | - */ |
|
| 48 | - public function changeSchema(IOutput $output, |
|
| 49 | - \Closure $schemaClosure, |
|
| 50 | - array $options):?ISchemaWrapper { |
|
| 51 | - /** @var ISchemaWrapper $schema */ |
|
| 52 | - $schema = $schemaClosure(); |
|
| 41 | + /** |
|
| 42 | + * @param IOutput $output |
|
| 43 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 44 | + * @param array $options |
|
| 45 | + * @return null|ISchemaWrapper |
|
| 46 | + * @since 17.0.0 |
|
| 47 | + */ |
|
| 48 | + public function changeSchema(IOutput $output, |
|
| 49 | + \Closure $schemaClosure, |
|
| 50 | + array $options):?ISchemaWrapper { |
|
| 51 | + /** @var ISchemaWrapper $schema */ |
|
| 52 | + $schema = $schemaClosure(); |
|
| 53 | 53 | |
| 54 | - if (!$schema->hasTable('calendar_reminders')) { |
|
| 55 | - $table = $schema->createTable('calendar_reminders'); |
|
| 54 | + if (!$schema->hasTable('calendar_reminders')) { |
|
| 55 | + $table = $schema->createTable('calendar_reminders'); |
|
| 56 | 56 | |
| 57 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 58 | - 'autoincrement' => true, |
|
| 59 | - 'notnull' => true, |
|
| 60 | - 'length' => 11, |
|
| 61 | - 'unsigned' => true, |
|
| 62 | - ]); |
|
| 63 | - $table->addColumn('calendar_id', Types::BIGINT, [ |
|
| 64 | - 'notnull' => true, |
|
| 65 | - 'length' => 11, |
|
| 66 | - ]); |
|
| 67 | - $table->addColumn('object_id', Types::BIGINT, [ |
|
| 68 | - 'notnull' => true, |
|
| 69 | - 'length' => 11, |
|
| 70 | - ]); |
|
| 71 | - $table->addColumn('is_recurring', Types::SMALLINT, [ |
|
| 72 | - 'notnull' => false, |
|
| 73 | - 'length' => 1, |
|
| 74 | - ]); |
|
| 75 | - $table->addColumn('uid', Types::STRING, [ |
|
| 76 | - 'notnull' => true, |
|
| 77 | - 'length' => 255, |
|
| 78 | - ]); |
|
| 79 | - $table->addColumn('recurrence_id', Types::BIGINT, [ |
|
| 80 | - 'notnull' => false, |
|
| 81 | - 'length' => 11, |
|
| 82 | - 'unsigned' => true, |
|
| 83 | - ]); |
|
| 84 | - $table->addColumn('is_recurrence_exception', Types::SMALLINT, [ |
|
| 85 | - 'notnull' => true, |
|
| 86 | - 'length' => 1, |
|
| 87 | - ]); |
|
| 88 | - $table->addColumn('event_hash', Types::STRING, [ |
|
| 89 | - 'notnull' => true, |
|
| 90 | - 'length' => 255, |
|
| 91 | - ]); |
|
| 92 | - $table->addColumn('alarm_hash', Types::STRING, [ |
|
| 93 | - 'notnull' => true, |
|
| 94 | - 'length' => 255, |
|
| 95 | - ]); |
|
| 96 | - $table->addColumn('type', Types::STRING, [ |
|
| 97 | - 'notnull' => true, |
|
| 98 | - 'length' => 255, |
|
| 99 | - ]); |
|
| 100 | - $table->addColumn('is_relative', Types::SMALLINT, [ |
|
| 101 | - 'notnull' => true, |
|
| 102 | - 'length' => 1, |
|
| 103 | - ]); |
|
| 104 | - $table->addColumn('notification_date', Types::BIGINT, [ |
|
| 105 | - 'notnull' => true, |
|
| 106 | - 'length' => 11, |
|
| 107 | - 'unsigned' => true, |
|
| 108 | - ]); |
|
| 109 | - $table->addColumn('is_repeat_based', Types::SMALLINT, [ |
|
| 110 | - 'notnull' => true, |
|
| 111 | - 'length' => 1, |
|
| 112 | - ]); |
|
| 57 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 58 | + 'autoincrement' => true, |
|
| 59 | + 'notnull' => true, |
|
| 60 | + 'length' => 11, |
|
| 61 | + 'unsigned' => true, |
|
| 62 | + ]); |
|
| 63 | + $table->addColumn('calendar_id', Types::BIGINT, [ |
|
| 64 | + 'notnull' => true, |
|
| 65 | + 'length' => 11, |
|
| 66 | + ]); |
|
| 67 | + $table->addColumn('object_id', Types::BIGINT, [ |
|
| 68 | + 'notnull' => true, |
|
| 69 | + 'length' => 11, |
|
| 70 | + ]); |
|
| 71 | + $table->addColumn('is_recurring', Types::SMALLINT, [ |
|
| 72 | + 'notnull' => false, |
|
| 73 | + 'length' => 1, |
|
| 74 | + ]); |
|
| 75 | + $table->addColumn('uid', Types::STRING, [ |
|
| 76 | + 'notnull' => true, |
|
| 77 | + 'length' => 255, |
|
| 78 | + ]); |
|
| 79 | + $table->addColumn('recurrence_id', Types::BIGINT, [ |
|
| 80 | + 'notnull' => false, |
|
| 81 | + 'length' => 11, |
|
| 82 | + 'unsigned' => true, |
|
| 83 | + ]); |
|
| 84 | + $table->addColumn('is_recurrence_exception', Types::SMALLINT, [ |
|
| 85 | + 'notnull' => true, |
|
| 86 | + 'length' => 1, |
|
| 87 | + ]); |
|
| 88 | + $table->addColumn('event_hash', Types::STRING, [ |
|
| 89 | + 'notnull' => true, |
|
| 90 | + 'length' => 255, |
|
| 91 | + ]); |
|
| 92 | + $table->addColumn('alarm_hash', Types::STRING, [ |
|
| 93 | + 'notnull' => true, |
|
| 94 | + 'length' => 255, |
|
| 95 | + ]); |
|
| 96 | + $table->addColumn('type', Types::STRING, [ |
|
| 97 | + 'notnull' => true, |
|
| 98 | + 'length' => 255, |
|
| 99 | + ]); |
|
| 100 | + $table->addColumn('is_relative', Types::SMALLINT, [ |
|
| 101 | + 'notnull' => true, |
|
| 102 | + 'length' => 1, |
|
| 103 | + ]); |
|
| 104 | + $table->addColumn('notification_date', Types::BIGINT, [ |
|
| 105 | + 'notnull' => true, |
|
| 106 | + 'length' => 11, |
|
| 107 | + 'unsigned' => true, |
|
| 108 | + ]); |
|
| 109 | + $table->addColumn('is_repeat_based', Types::SMALLINT, [ |
|
| 110 | + 'notnull' => true, |
|
| 111 | + 'length' => 1, |
|
| 112 | + ]); |
|
| 113 | 113 | |
| 114 | - $table->setPrimaryKey(['id']); |
|
| 115 | - $table->addIndex(['object_id'], 'calendar_reminder_objid'); |
|
| 116 | - $table->addIndex(['uid', 'recurrence_id'], 'calendar_reminder_uidrec'); |
|
| 114 | + $table->setPrimaryKey(['id']); |
|
| 115 | + $table->addIndex(['object_id'], 'calendar_reminder_objid'); |
|
| 116 | + $table->addIndex(['uid', 'recurrence_id'], 'calendar_reminder_uidrec'); |
|
| 117 | 117 | |
| 118 | - return $schema; |
|
| 119 | - } |
|
| 118 | + return $schema; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - return null; |
|
| 122 | - } |
|
| 121 | + return null; |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -31,51 +31,51 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class NotificationProviderManager { |
| 33 | 33 | |
| 34 | - /** @var INotificationProvider[] */ |
|
| 35 | - private $providers = []; |
|
| 34 | + /** @var INotificationProvider[] */ |
|
| 35 | + private $providers = []; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Checks whether a provider for a given ACTION exists |
|
| 39 | - * |
|
| 40 | - * @param string $type |
|
| 41 | - * @return bool |
|
| 42 | - */ |
|
| 43 | - public function hasProvider(string $type):bool { |
|
| 44 | - return (\in_array($type, ReminderService::REMINDER_TYPES, true) |
|
| 45 | - && isset($this->providers[$type])); |
|
| 46 | - } |
|
| 37 | + /** |
|
| 38 | + * Checks whether a provider for a given ACTION exists |
|
| 39 | + * |
|
| 40 | + * @param string $type |
|
| 41 | + * @return bool |
|
| 42 | + */ |
|
| 43 | + public function hasProvider(string $type):bool { |
|
| 44 | + return (\in_array($type, ReminderService::REMINDER_TYPES, true) |
|
| 45 | + && isset($this->providers[$type])); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Get provider for a given ACTION |
|
| 50 | - * |
|
| 51 | - * @param string $type |
|
| 52 | - * @return INotificationProvider |
|
| 53 | - * @throws NotificationProvider\ProviderNotAvailableException |
|
| 54 | - * @throws NotificationTypeDoesNotExistException |
|
| 55 | - */ |
|
| 56 | - public function getProvider(string $type):INotificationProvider { |
|
| 57 | - if (in_array($type, ReminderService::REMINDER_TYPES, true)) { |
|
| 58 | - if (isset($this->providers[$type])) { |
|
| 59 | - return $this->providers[$type]; |
|
| 60 | - } |
|
| 61 | - throw new NotificationProvider\ProviderNotAvailableException($type); |
|
| 62 | - } |
|
| 63 | - throw new NotificationTypeDoesNotExistException($type); |
|
| 64 | - } |
|
| 48 | + /** |
|
| 49 | + * Get provider for a given ACTION |
|
| 50 | + * |
|
| 51 | + * @param string $type |
|
| 52 | + * @return INotificationProvider |
|
| 53 | + * @throws NotificationProvider\ProviderNotAvailableException |
|
| 54 | + * @throws NotificationTypeDoesNotExistException |
|
| 55 | + */ |
|
| 56 | + public function getProvider(string $type):INotificationProvider { |
|
| 57 | + if (in_array($type, ReminderService::REMINDER_TYPES, true)) { |
|
| 58 | + if (isset($this->providers[$type])) { |
|
| 59 | + return $this->providers[$type]; |
|
| 60 | + } |
|
| 61 | + throw new NotificationProvider\ProviderNotAvailableException($type); |
|
| 62 | + } |
|
| 63 | + throw new NotificationTypeDoesNotExistException($type); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Registers a new provider |
|
| 68 | - * |
|
| 69 | - * @param string $providerClassName |
|
| 70 | - * @throws \OCP\AppFramework\QueryException |
|
| 71 | - */ |
|
| 72 | - public function registerProvider(string $providerClassName):void { |
|
| 73 | - $provider = \OC::$server->query($providerClassName); |
|
| 66 | + /** |
|
| 67 | + * Registers a new provider |
|
| 68 | + * |
|
| 69 | + * @param string $providerClassName |
|
| 70 | + * @throws \OCP\AppFramework\QueryException |
|
| 71 | + */ |
|
| 72 | + public function registerProvider(string $providerClassName):void { |
|
| 73 | + $provider = \OC::$server->query($providerClassName); |
|
| 74 | 74 | |
| 75 | - if (!$provider instanceof INotificationProvider) { |
|
| 76 | - throw new \InvalidArgumentException('Invalid notification provider registered'); |
|
| 77 | - } |
|
| 75 | + if (!$provider instanceof INotificationProvider) { |
|
| 76 | + throw new \InvalidArgumentException('Invalid notification provider registered'); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $this->providers[$provider::NOTIFICATION_TYPE] = $provider; |
|
| 80 | - } |
|
| 79 | + $this->providers[$provider::NOTIFICATION_TYPE] = $provider; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -26,15 +26,15 @@ |
||
| 26 | 26 | |
| 27 | 27 | class NotificationTypeDoesNotExistException extends \Exception { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * NotificationTypeDoesNotExistException constructor. |
|
| 31 | - * |
|
| 32 | - * @since 16.0.0 |
|
| 33 | - * |
|
| 34 | - * @param string $type ReminderType |
|
| 35 | - */ |
|
| 36 | - public function __construct(string $type) { |
|
| 37 | - parent::__construct("Type $type is not an accepted type of notification"); |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * NotificationTypeDoesNotExistException constructor. |
|
| 31 | + * |
|
| 32 | + * @since 16.0.0 |
|
| 33 | + * |
|
| 34 | + * @param string $type ReminderType |
|
| 35 | + */ |
|
| 36 | + public function __construct(string $type) { |
|
| 37 | + parent::__construct("Type $type is not an accepted type of notification"); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -25,15 +25,15 @@ |
||
| 25 | 25 | |
| 26 | 26 | class ProviderNotAvailableException extends \Exception { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * ProviderNotAvailableException constructor. |
|
| 30 | - * |
|
| 31 | - * @since 16.0.0 |
|
| 32 | - * |
|
| 33 | - * @param string $type ReminderType |
|
| 34 | - */ |
|
| 35 | - public function __construct(string $type) { |
|
| 36 | - parent::__construct("No notification provider for type $type available"); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * ProviderNotAvailableException constructor. |
|
| 30 | + * |
|
| 31 | + * @since 16.0.0 |
|
| 32 | + * |
|
| 33 | + * @param string $type ReminderType |
|
| 34 | + */ |
|
| 35 | + public function __construct(string $type) { |
|
| 36 | + parent::__construct("No notification provider for type $type available"); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | } |