namespace App\Slack;
+use Cubist\Backpack\Facades\App;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Pnz\MattermostClient\ApiClient;
use Pnz\MattermostClient\HttpClientConfigurator;
const fluidbookQuoteChannel = 'tswc7buu1bf9ixdccfqmo36s5r';
const fluidbookPreviewAlertsChannel = 'y1z7rdtppbg1jr91o8f6prcbcc';
- const fluidbookFilesChannel='6sgtn7rrw3buz8fqftm936oqer';
+ const fluidbookFilesChannel = '6sgtn7rrw3buz8fqftm936oqer';
+ const endpoint = 'https://mm.cubedesigners.com/api/v4';
+ const email = 'vincent+toolbox@cubedesigners.com';
+ const password = 'HtMYveJ3%8HMnWooXsm9';
+ const team = 'cubedesigners';
protected static function _client(): ApiClient
{
if (null === self::$_client) {
-
- $endpoint = 'https://mm.cubedesigners.com/api/v4';
- $username = 'vincent+toolbox@cubedesigners.com';
- $password = 'HtMYveJ3%8HMnWooXsm9';
-
$configurator = (new HttpClientConfigurator())
- ->setEndpoint($endpoint)
- ->setCredentials($username, $password);
+ ->setEndpoint(self::endpoint)
+ ->setCredentials(self::email, self::password);
self::$_client = ApiClient::configure($configurator);
}
return self::$_client;
public static function send($channel, $subject, $text, $actions = [], $repeatActions = true, $from = 'Fluidbook Toolbox')
{
- Log::debug(json_encode(func_get_args()));
$markdown = '';
if ($text) {
$markdown .= $text . "\n";
'channel_id' => $channel,
'props' => $props,
]);
+ return $response->getId();
} catch (\Exception $e) {
Log::critical($e);
Log::critical($e->getMessage() . ' // ' . $from . ' // ' . $channel . ' // ' . $text . ' // ' . $markdown);
return self::_client()->posts()->deletePost($postId)->getStatus();
}
- public static function addReaction($channel, $ts, $reaction)
+ public static function addReaction($postId, $emoji, $userId = null)
+ {
+ if (null === $userId) {
+ $userId = self::getUserIdByEmail(self::email);
+ }
+ return self::_client()->posts()->addReaction(['post_id' => $postId, 'emoji_name' => $emoji, 'user_id' => $userId]);
+ }
+
+ public static function getUserIdByEmail($email)
{
- return self::_client()->reactionsAdd(['channel' => $channel, 'timestamp' => $ts, 'name' => $reaction]);
+ return Cache::remember('mm_user_by_email_' . $email, 7200, function () use ($email) {
+ return self::_client()->users()->getUserByEmail($email)->getId();
+ });
}
+
+ public static function getChannelIdByName($channel, $teamName = null)
+ {
+ if ($teamName === null) {
+ $teamName = self::team;
+ }
+ return Cache::remember('mm_channel_id_by_name_' . $channel . '_' . $teamName, 7200, function () use ($channel, $teamName) {
+ return self::_client()->channels()->getChannelByNameAndTeamName($teamName, $channel)->getId();
+ });
+ }
+
+
}
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "534e3e6f2014dd23ae4c7ad3f482c968",
+ "content-hash": "9aabb63950a197c861594703ffd8b56d",
"packages": [
{
"name": "archtechx/enums",
},
{
"name": "norkunas/youtube-dl-php",
- "version": "v2.6.0",
+ "version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/norkunas/youtube-dl-php.git",
- "reference": "c02b9c45a76e0d1978136caa261fcc17d3d91b61"
+ "reference": "c0ef03ace6ab794ef94ea72e4b083d608d64b754"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/norkunas/youtube-dl-php/zipball/c02b9c45a76e0d1978136caa261fcc17d3d91b61",
- "reference": "c02b9c45a76e0d1978136caa261fcc17d3d91b61",
+ "url": "https://api.github.com/repos/norkunas/youtube-dl-php/zipball/c0ef03ace6ab794ef94ea72e4b083d608d64b754",
+ "reference": "c0ef03ace6ab794ef94ea72e4b083d608d64b754",
"shasum": ""
},
"require": {
},
"require-dev": {
"mikey179/vfsstream": "^1.6.11",
- "php-cs-fixer/shim": "^3.49",
- "phpstan/phpstan": "^1.10.57",
- "phpstan/phpstan-phpunit": "^1.3.15",
- "phpstan/phpstan-strict-rules": "^1.5.2",
- "symfony/phpunit-bridge": "^6.4.3"
+ "php-cs-fixer/shim": "^3.60",
+ "phpstan/phpstan": "^1.11.8",
+ "phpstan/phpstan-phpunit": "^1.4.0",
+ "phpstan/phpstan-strict-rules": "^1.6.0",
+ "symfony/phpunit-bridge": "^6.4.10"
},
"type": "library",
"extra": {
],
"support": {
"issues": "https://github.com/norkunas/youtube-dl-php/issues",
- "source": "https://github.com/norkunas/youtube-dl-php/tree/v2.6.0"
+ "source": "https://github.com/norkunas/youtube-dl-php/tree/v2.7.0"
},
- "time": "2024-02-28T05:14:01+00:00"
+ "time": "2024-08-28T08:22:20+00:00"
},
{
"name": "nothingworks/blade-svg",
"time": "2024-07-20T21:41:07+00:00"
},
{
- "name": "pnz/mattermost-client",
- "version": "2.x-dev",
+ "name": "pnz/json-exception",
+ "version": "v1.0.1",
"source": {
"type": "git",
- "url": "https://github.com/thePanz/MattermostClient.git",
- "reference": "74c14f78bce005131da44d293d45cbd04aaedb3d"
+ "url": "https://github.com/thePanz/json-exception.git",
+ "reference": "cce24ccdb59f6eecb6cb45dbdc8695808f6d64d7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thePanz/MattermostClient/zipball/74c14f78bce005131da44d293d45cbd04aaedb3d",
- "reference": "74c14f78bce005131da44d293d45cbd04aaedb3d",
+ "url": "https://api.github.com/repos/thePanz/json-exception/zipball/cce24ccdb59f6eecb6cb45dbdc8695808f6d64d7",
+ "reference": "cce24ccdb59f6eecb6cb45dbdc8695808f6d64d7",
"shasum": ""
},
"require": {
"ext-json": "*",
- "php": "^8.1",
+ "php": "^7.0 || ^8.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Pnz\\JsonException\\": "src/"
+ },
+ "classmap": [
+ "src/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "GPL-3.0"
+ ],
+ "description": "Json decode/encode library with exception throwing on error.",
+ "keywords": [
+ "json"
+ ],
+ "support": {
+ "issues": "https://github.com/thePanz/json-exception/issues",
+ "source": "https://github.com/thePanz/json-exception/tree/v1.0.1"
+ },
+ "time": "2021-08-18T13:32:12+00:00"
+ },
+ {
+ "name": "pnz/mattermost-client",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/enhydrav/mattermostclient.git",
+ "reference": "2562057e91f255cace2d304af6ac4c61740d74bb"
+ },
+ "require": {
+ "ext-json": "*",
+ "php": "^7.4 || ^8.0",
"php-http/client-common": "^2.0",
- "php-http/discovery": "^1.17",
- "php-http/httplug": "^2.1",
+ "php-http/discovery": "^1.7",
+ "php-http/httplug": "^2.0",
"php-http/multipart-stream-builder": "^1.1",
- "psr/http-client-implementation": "*",
- "psr/http-factory-implementation": "*",
- "psr/http-message": "^1.0"
+ "pnz/json-exception": "^1.0"
},
"require-dev": {
- "nyholm/psr7": "^1.8",
- "php-cs-fixer/shim": "^v3.34",
- "php-http/curl-client": "^2.3",
- "php-http/mock-client": "^1.6",
- "phpstan/extension-installer": "^1.3",
- "phpstan/phpstan": "^1.10",
- "phpstan/phpstan-phpunit": "^1.3",
- "phpunit/phpunit": "^10.5",
- "rector/rector": "^0.18.12"
+ "nyholm/psr7": "^1.2.1",
+ "php-http/curl-client": "^2.0",
+ "php-http/message": "^1.8",
+ "php-http/message-factory": "^1.0",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan-phpunit": "^0.11.2",
+ "phpstan/phpstan-shim": "^0.11",
+ "phpunit/phpunit": "^7.5",
+ "psr/http-message": "^1.0.1"
},
+ "default-branch": true,
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.1.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Pnz\\MattermostClient\\": "src/"
}
},
- "notification-url": "https://packagist.org/downloads/",
+ "autoload-dev": {
+ "psr-4": {
+ "Pnz\\MattermostClient\\Tests\\": "tests/"
+ }
+ },
+ "scripts": {
+ "ci": [
+ "@phpcs",
+ "@phpstan",
+ "@test-ci"
+ ],
+ "phpstan": [
+ "vendor/bin/phpstan analyze --level=7 src/ tests/"
+ ],
+ "phpcs": [
+ "vendor/bin/php-cs-fixer fix --dry-run --verbose --ansi"
+ ],
+ "phpcs-install": [
+ "curl -L https://cs.symfony.com/download/php-cs-fixer-v2.phar -o vendor/bin/php-cs-fixer && chmod u+x vendor/bin/php-cs-fixer"
+ ],
+ "phpcs-fix": [
+ "vendor/bin/php-cs-fixer fix --verbose --ansi"
+ ],
+ "test": [
+ "vendor/bin/phpunit"
+ ],
+ "test-ci": [
+ "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
+ ]
+ },
"license": [
"MIT"
],
],
"description": "Mattermost APi Client for PHP",
"keywords": [
- "Mattermost",
- "api"
+ "api",
+ "mattermost"
],
- "support": {
- "issues": "https://github.com/thePanz/MattermostClient/issues",
- "source": "https://github.com/thePanz/MattermostClient/tree/2.x"
- },
- "time": "2023-12-20T14:23:35+00:00"
+ "time": "2023-09-07T09:16:48+00:00"
},
{
"name": "prologue/alerts",
},
{
"name": "spatie/laravel-package-tools",
- "version": "1.16.4",
+ "version": "1.16.5",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-package-tools.git",
- "reference": "ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53"
+ "reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53",
- "reference": "ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53",
+ "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/c7413972cf22ffdff97b68499c22baa04eddb6a2",
+ "reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/spatie/laravel-package-tools/issues",
- "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.4"
+ "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.5"
},
"funding": [
{
"type": "github"
}
],
- "time": "2024-03-20T07:29:11+00:00"
+ "time": "2024-08-27T18:56:10+00:00"
},
{
"name": "spatie/laravel-permission",
},
{
"name": "composer/pcre",
- "version": "3.3.0",
+ "version": "3.3.1",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
- "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81"
+ "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/pcre/zipball/1637e067347a0c40bbb1e3cd786b20dcab556a81",
- "reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81",
+ "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4",
+ "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
- "source": "https://github.com/composer/pcre/tree/3.3.0"
+ "source": "https://github.com/composer/pcre/tree/3.3.1"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2024-08-19T19:43:53+00:00"
+ "time": "2024-08-27T18:44:43+00:00"
},
{
"name": "doctrine/instantiator",
},
{
"name": "phpstan/phpdoc-parser",
- "version": "1.29.1",
+ "version": "1.30.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
- "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4"
+ "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4",
- "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/5ceb0e384997db59f38774bf79c2a6134252c08f",
+ "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f",
"shasum": ""
},
"require": {
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
- "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1"
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.0"
},
- "time": "2024-05-31T08:52:43+00:00"
+ "time": "2024-08-29T09:54:52+00:00"
},
{
"name": "phpunit/php-code-coverage",