feat: add room share activities
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 695 B |
|
@ -12,8 +12,11 @@
|
|||
version="1.0"
|
||||
viewBox="0 0 32 32"
|
||||
id="svg4"
|
||||
sodipodi:docname="app-dark.svg"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
|
||||
sodipodi:docname="room-created.svg"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
inkscape:export-filename="/home/klaus/Repos/cloud_bbb/img/actions/room-created.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
|
@ -22,7 +25,7 @@
|
|||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
|
@ -41,11 +44,11 @@
|
|||
inkscape:window-height="997"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.375"
|
||||
inkscape:cx="13.46269"
|
||||
inkscape:cy="7.070207"
|
||||
inkscape:window-x="2110"
|
||||
inkscape:window-y="585"
|
||||
inkscape:zoom="10.429825"
|
||||
inkscape:cx="-15.100081"
|
||||
inkscape:cy="6.5908126"
|
||||
inkscape:window-x="1889"
|
||||
inkscape:window-y="504"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
|
@ -54,19 +57,14 @@
|
|||
id="rect817"
|
||||
inkscape:connector-curvature="0" />
|
||||
<g
|
||||
id="g891"
|
||||
transform="matrix(0.72859037,0,0,0.72859037,4.3425539,7.2153805)"
|
||||
style="fill:#000000">
|
||||
aria-label="+"
|
||||
transform="matrix(1.5934936,0,0,1.2502401,-6.542738,-6.5950957)"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:23.68428612px;line-height:125%;font-family:'Helvetica Neue';-inkscape-font-specification:'Helvetica Neue';letter-spacing:0px;word-spacing:0px;fill:#44aa00;fill-opacity:1;stroke:none;stroke-width:1.26880109px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
id="text817">
|
||||
<path
|
||||
d="m 13.196362,25.27142 0.307896,0.189474 0.213158,-0.16579 v 0.09474 l 0.236843,-0.09474 0.09474,0.09474 0.142106,-0.09474 h 0.568423 l 0.142106,-0.07105 h 0.33158 l 0.378948,-1.018424 0.118422,-0.82895 -0.118422,-0.402633 0.07105,-0.09474 V 21.95562 l 0.09474,-0.947372 0.07105,-1.894743 h 1.634216 l 1.278951,-0.07105 0.757898,-0.236842 0.16579,-0.16579 v -0.307896 l 0.09474,-0.378949 v -0.260527 l 0.07105,-0.307896 v -0.521054 l -0.402633,-0.49737 h -0.213159 l -0.09474,-0.07105 h -3.292116 v -2.581587 l -0.16579,-1.6579 -0.473686,-1.184214 -0.142105,-0.142106 h -0.781582 l -0.33158,0.07105 -0.07105,0.189474 -0.236842,-0.118421 h -0.378949 l -0.16579,0.16579 v 5.257911 h -2.98422 l -1.16053,0.236843 -0.3552643,0.16579 -0.1894743,0.615792 0.071053,0.07105 -0.071053,0.473686 0.094737,0.189474 -0.094737,0.189475 -0.094737,0.473685 0.1421058,0.16579 2.2736908,0.16579 h 1.752638 l 0.450001,0.07105 -0.09474,3.955276 0.09474,0.99474 z"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Bocadillo;-inkscape-font-specification:Bocadillo;fill:#44aa00;stroke-width:1.26880109px"
|
||||
id="path819"
|
||||
d="m 16,16.40625 a 9.4915257,9.4915257 0 0 0 -9.4921875,9.492188 9.4915257,9.4915257 0 0 0 0.3574219,2.576171 H 25.126953 A 9.4915257,9.4915257 0 0 0 25.492188,25.898438 9.4915257,9.4915257 0 0 0 16,16.40625 Z"
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3.37037015;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill"
|
||||
inkscape:connector-curvature="0" />
|
||||
<circle
|
||||
r="6.2372885"
|
||||
cy="12.338983"
|
||||
cx="16"
|
||||
id="path819-1"
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.21481466;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 666 B After Width: | Height: | Size: 704 B |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 611 B |
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="32"
|
||||
width="32"
|
||||
version="1.0"
|
||||
viewBox="0 0 32 32"
|
||||
id="svg4"
|
||||
sodipodi:docname="share-created.svg"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
inkscape:export-filename="/home/klaus/Repos/cloud_bbb/img/actions/share-created.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1907"
|
||||
inkscape:window-height="997"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.375"
|
||||
inkscape:cx="-50.305084"
|
||||
inkscape:cy="5.7142748"
|
||||
inkscape:window-x="1511"
|
||||
inkscape:window-y="343"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4"
|
||||
showguides="false" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.48244119;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="M 6.140625,2 C 3.8448872,2 2,3.9362265 2,6.2421875 V 25.757812 C 2,28.063773 3.8448872,30 6.140625,30 h 19.71875 C 28.155113,30 30,28.063773 30,25.757812 V 6.2421875 C 30,3.9362265 28.155113,2 25.859375,2 Z m 0,2.4824219 h 19.71875 c 0.917462,0 1.658203,0.7417266 1.658203,1.7597656 V 25.757812 c 0,1.01804 -0.740741,1.759766 -1.658203,1.759766 H 6.140625 c -0.9174623,0 -1.6582031,-0.741726 -1.6582031,-1.759766 V 6.2421875 c 0,-1.018039 0.7407408,-1.7597656 1.6582031,-1.7597656 z"
|
||||
id="rect817"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#008000"
|
||||
d="m 20.363645,9.0002321 a 2.5,2.5 0 0 0 -2.5,2.4999999 2.5,2.5 0 0 0 0.0059,0.128906 l -4.904297,2.451172 a 2.5,2.5 0 0 0 -1.601563,-0.580078 2.5,2.5 0 0 0 -2.5,2.5 2.5,2.5 0 0 0 2.5,2.5 2.5,2.5 0 0 0 1.601563,-0.582032 l 4.90625,2.453125 a 2.5,2.5 0 0 0 -0.0078,0.128907 2.5,2.5 0 0 0 2.5,2.5 2.5,2.5 0 0 0 2.5,-2.5 2.5,2.5 0 0 0 -2.5,-2.5 2.5,2.5 0 0 0 -1.599609,0.582031 l -4.90625,-2.453125 a 2.5,2.5 0 0 0 0.0059,-0.128906 2.5,2.5 0 0 0 -0.0039,-0.128907 L 18.762083,13.4182 a 2.5,2.5 0 0 0 1.601562,0.582032 2.5,2.5 0 0 0 2.5,-2.5 2.5,2.5 0 0 0 -2.5,-2.4999999 z"
|
||||
id="circle814"
|
||||
inkscape:connector-curvature="0" />
|
||||
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 596 B |
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="32"
|
||||
width="32"
|
||||
version="1.0"
|
||||
viewBox="0 0 32 32"
|
||||
id="svg4"
|
||||
sodipodi:docname="share-deleted.svg"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
inkscape:export-filename="/home/klaus/Repos/cloud_bbb/img/actions/share-deleted.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1907"
|
||||
inkscape:window-height="997"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.375"
|
||||
inkscape:cx="-50.576271"
|
||||
inkscape:cy="6.3922409"
|
||||
inkscape:window-x="1511"
|
||||
inkscape:window-y="343"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4"
|
||||
showguides="false" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.48244119;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="M 6.140625,2 C 3.8448872,2 2,3.9362265 2,6.2421875 V 25.757812 C 2,28.063773 3.8448872,30 6.140625,30 h 19.71875 C 28.155113,30 30,28.063773 30,25.757812 V 6.2421875 C 30,3.9362265 28.155113,2 25.859375,2 Z m 0,2.4824219 h 19.71875 c 0.917462,0 1.658203,0.7417266 1.658203,1.7597656 V 25.757812 c 0,1.01804 -0.740741,1.759766 -1.658203,1.759766 H 6.140625 c -0.9174623,0 -1.6582031,-0.741726 -1.6582031,-1.759766 V 6.2421875 c 0,-1.018039 0.7407408,-1.7597656 1.6582031,-1.7597656 z"
|
||||
id="rect817"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#ff0000"
|
||||
d="m 20.363645,9.0002321 a 2.5,2.5 0 0 0 -2.5,2.4999999 2.5,2.5 0 0 0 0.0059,0.128906 l -4.904297,2.451172 a 2.5,2.5 0 0 0 -1.601563,-0.580078 2.5,2.5 0 0 0 -2.5,2.5 2.5,2.5 0 0 0 2.5,2.5 2.5,2.5 0 0 0 1.601563,-0.582032 l 4.90625,2.453125 a 2.5,2.5 0 0 0 -0.0078,0.128907 2.5,2.5 0 0 0 2.5,2.5 2.5,2.5 0 0 0 2.5,-2.5 2.5,2.5 0 0 0 -2.5,-2.5 2.5,2.5 0 0 0 -1.599609,0.582031 l -4.90625,-2.453125 a 2.5,2.5 0 0 0 0.0059,-0.128906 2.5,2.5 0 0 0 -0.0039,-0.128907 L 18.762083,13.4182 a 2.5,2.5 0 0 0 1.601562,0.582032 2.5,2.5 0 0 0 2.5,-2.5 2.5,2.5 0 0 0 -2.5,-2.4999999 z"
|
||||
id="circle814"
|
||||
inkscape:connector-curvature="0" />
|
||||
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
|
@ -3,11 +3,13 @@
|
|||
namespace OCA\BigBlueButton\Activity;
|
||||
|
||||
use OCA\BigBlueButton\AppInfo\Application;
|
||||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCP\Activity\IProvider;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\Activity\IManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\IUser;
|
||||
|
@ -20,6 +22,12 @@ class Provider implements IProvider {
|
|||
/** @var string */
|
||||
public const ROOM_DELETED = 'room_deleted';
|
||||
|
||||
/** @var string */
|
||||
public const SHARE_CREATED = 'share_created';
|
||||
|
||||
/** @var string */
|
||||
public const SHARE_DELETED = 'share_deleted';
|
||||
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
|
@ -29,6 +37,9 @@ class Provider implements IProvider {
|
|||
/** @var IUserManager */
|
||||
protected $userManager;
|
||||
|
||||
/** @var IGroupManager */
|
||||
protected $groupManager;
|
||||
|
||||
/** @var IURLGenerator */
|
||||
protected $url;
|
||||
|
||||
|
@ -38,11 +49,13 @@ class Provider implements IProvider {
|
|||
public function __construct(
|
||||
IManager $manager,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
IURLGenerator $url,
|
||||
IFactory $languageFactory
|
||||
) {
|
||||
$this->activityManager = $manager;
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->url = $url;
|
||||
$this->languageFactory = $languageFactory;
|
||||
}
|
||||
|
@ -60,8 +73,10 @@ class Provider implements IProvider {
|
|||
$this->parseRoomCreated($event);
|
||||
} elseif ($subject === self::ROOM_DELETED) {
|
||||
$this->parseRoomDeleted($event);
|
||||
} else {
|
||||
$event->setParsedSubject('Unknown subject: ' . $subject);
|
||||
} elseif ($subject === self::SHARE_CREATED) {
|
||||
$this->parseShareCreated($event);
|
||||
} elseif ($subject === self::SHARE_DELETED) {
|
||||
$this->parseShareDeleted($event);
|
||||
}
|
||||
|
||||
return $event;
|
||||
|
@ -91,6 +106,40 @@ class Provider implements IProvider {
|
|||
$this->setIcon($event, 'room-deleted');
|
||||
}
|
||||
|
||||
private function parseShareCreated(IEvent $event) {
|
||||
$params = $event->getSubjectParameters();
|
||||
|
||||
if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) {
|
||||
$subject = $this->l->t('You shared the room %s with {shareWith}.', [$params['name']]);
|
||||
} else {
|
||||
$subject = $this->l->t('{user} shared the room %s with you.', [$params['name']]);
|
||||
}
|
||||
|
||||
$this->setSubjects($event, $subject, [
|
||||
'user' => $this->getUser($event->getAuthor()),
|
||||
'shareWith' => $params['shareType'] === RoomShare::SHARE_TYPE_USER ? $this->getUser($params['shareWith']) : $this->getGroup($params['shareWith']),
|
||||
]);
|
||||
|
||||
$this->setIcon($event, 'share-created');
|
||||
}
|
||||
|
||||
private function parseShareDeleted(IEvent $event) {
|
||||
$params = $event->getSubjectParameters();
|
||||
|
||||
if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) {
|
||||
$subject = $this->l->t('You unshared the room %s with {shareWith}.', [$params['name']]);
|
||||
} else {
|
||||
$subject = $this->l->t('{user} unshared the room %s with you.', [$params['name']]);
|
||||
}
|
||||
|
||||
$this->setSubjects($event, $subject, [
|
||||
'user' => $this->getUser($event->getAuthor()),
|
||||
'shareWith' => $params['shareType'] === RoomShare::SHARE_TYPE_USER ? $this->getUser($params['shareWith']) : $this->getGroup($params['shareWith']),
|
||||
]);
|
||||
|
||||
$this->setIcon($event, 'share-deleted');
|
||||
}
|
||||
|
||||
private function setIcon(IEvent $event, string $baseName) {
|
||||
if ($this->activityManager->getRequirePNG()) {
|
||||
$imagePath = $this->url->imagePath(Application::ID, 'actions/'.$baseName.'.png');
|
||||
|
@ -134,4 +183,22 @@ class Provider implements IProvider {
|
|||
'name' => $uid,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getGroup($uid) {
|
||||
$group = $this->groupManager->get($uid);
|
||||
|
||||
if ($group !== null) {
|
||||
return [
|
||||
'type' => 'user-group',
|
||||
'id' => $group->getGID(),
|
||||
'name' => $group->getDisplayName(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => 'user-group',
|
||||
'id' => $uid,
|
||||
'name' => $uid,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ class RoomListener implements IEventListener {
|
|||
|
||||
public function handle(Event $event): void {
|
||||
if ($event instanceof RoomCreatedEvent) {
|
||||
$subject = Provider::ROOM_CREATED;
|
||||
$subject = Provider::SHARE_CREATED;
|
||||
} elseif ($event instanceof RoomDeletedEvent) {
|
||||
$subject = Provider::ROOM_DELETED;
|
||||
$subject = Provider::SHARE_DELETED;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Activity;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Activity\IManager as IActivityManager;
|
||||
use OCP\IGroupManager;
|
||||
use OCA\BigBlueButton\Event\RoomShareCreatedEvent;
|
||||
use OCA\BigBlueButton\Event\RoomShareDeletedEvent;
|
||||
use OCA\BigBlueButton\AppInfo\Application;
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
use OCA\BigBlueButton\Db\RoomShare;
|
||||
use OCA\BigBlueButton\Service\RoomService;
|
||||
|
||||
class RoomShareListener implements IEventListener {
|
||||
|
||||
/** @var IActivityManager */
|
||||
private $activityManager;
|
||||
|
||||
/** @var RoomService */
|
||||
private $roomService;
|
||||
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
||||
public function __construct(
|
||||
IActivityManager $activityManager,
|
||||
RoomService $roomService,
|
||||
IGroupManager $groupManager) {
|
||||
$this->activityManager = $activityManager;
|
||||
$this->roomService = $roomService;
|
||||
$this->groupManager = $groupManager;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if ($event instanceof RoomShareCreatedEvent) {
|
||||
$subject = Provider::SHARE_CREATED;
|
||||
} elseif ($event instanceof RoomShareDeletedEvent) {
|
||||
$subject = Provider::SHARE_DELETED;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
$share = $event->getRoomShare();
|
||||
$shareType = $share->getShareType();
|
||||
$room = $this->roomService->find($share->getRoomId());
|
||||
|
||||
if ($shareType === RoomShare::SHARE_TYPE_USER) {
|
||||
$this->shareWithUser($subject, $room, $share);
|
||||
} elseif ($shareType === RoomShare::SHARE_TYPE_GROUP) {
|
||||
$this->shareWithGroup($subject, $room, $share);
|
||||
}
|
||||
}
|
||||
|
||||
private function shareWithUser(string $subject, Room $room, RoomShare $share) {
|
||||
$this->createActivityEvent($subject, $room->getUserId(), $room, $share);
|
||||
$this->createActivityEvent($subject, $share->getShareWith(), $room, $share);
|
||||
}
|
||||
|
||||
private function shareWithGroup(string $subject, Room $room, RoomShare $share) {
|
||||
$this->createActivityEvent($subject, $room->getUserId(), $room, $share);
|
||||
|
||||
$group = $this->groupManager->get($share->getShareWith());
|
||||
|
||||
if ($group === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($group->getUsers() as $user) {
|
||||
$this->createActivityEvent($subject, $user->getUID(), $room, $share);
|
||||
}
|
||||
}
|
||||
|
||||
private function createActivityEvent(string $subject, string $affectedUser, Room $room, RoomShare $roomShare) {
|
||||
$activityEvent = $this->activityManager->generateEvent();
|
||||
|
||||
$activityEvent->setApp(Application::ID);
|
||||
$activityEvent->setType(Setting::Identifier);
|
||||
$activityEvent->setAffectedUser($affectedUser);
|
||||
$activityEvent->setSubject($subject, [
|
||||
'id' => $room->getId(),
|
||||
'name' => $room->getName(),
|
||||
'shareType' => $roomShare->getShareType(),
|
||||
'shareWith' => $roomShare->getShareWith(),
|
||||
'permission' => $roomShare->getPermission(),
|
||||
]);
|
||||
|
||||
$this->activityManager->publish($activityEvent);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,9 @@ use \OCA\BigBlueButton\Middleware\JoinMiddleware;
|
|||
use \OCA\BigBlueButton\Event\RoomCreatedEvent;
|
||||
use \OCA\BigBlueButton\Event\RoomDeletedEvent;
|
||||
use \OCA\BigBlueButton\Activity\RoomListener;
|
||||
use \OCA\BigBlueButton\Event\RoomShareCreatedEvent;
|
||||
use \OCA\BigBlueButton\Event\RoomShareDeletedEvent;
|
||||
use \OCA\BigBlueButton\Activity\RoomShareListener;
|
||||
|
||||
if ((@include_once __DIR__ . '/../../vendor/autoload.php') === false) {
|
||||
throw new \Exception('Cannot include autoload. Did you run install dependencies using composer?');
|
||||
|
@ -28,6 +31,9 @@ class Application extends App {
|
|||
$dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class);
|
||||
$dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class);
|
||||
|
||||
$dispatcher->addServiceListener(RoomShareCreatedEvent::class, RoomShareListener::class);
|
||||
$dispatcher->addServiceListener(RoomShareDeletedEvent::class, RoomShareListener::class);
|
||||
|
||||
$container->registerMiddleWare(JoinMiddleware::class);
|
||||
|
||||
$config = $container->query(IConfig::class);
|
||||
|
|
|
@ -11,7 +11,7 @@ abstract class RoomShareEvent extends Event {
|
|||
private $roomShare;
|
||||
|
||||
public function __construct(RoomShare $roomShare) {
|
||||
$this->roomId = $roomShare;
|
||||
$this->roomShare = $roomShare;
|
||||
}
|
||||
|
||||
public function getRoomShare(): RoomShare {
|
||||
|
|