gnello / php-mattermost-driver Goto Github PK
View Code? Open in Web Editor NEWThe PHP Driver to interact with the Mattermost Web Service API.
License: Apache License 2.0
The PHP Driver to interact with the Mattermost Web Service API.
License: Apache License 2.0
According to https://api.mattermost.com/#tag/channels%2Fpaths%2F~1teams~1%7Bteam_id%7D~1channels~1search%2Fpost
a HTTP Post was expected but in the code there is a get :
About that, can't find an example, to inject data in post body.. :'( can you provide an example for that ?
Best regards,
And many thanks to share your work !
Hi,
I'm a first time user, the ReactionModel seems a bit empty, I'm not finding this endpoint e.g.: https://api.mattermost.com/#tag/reactions/paths/~1users~1{user_id}~1posts~1{post_id}~1reactions~1{emoji_name}/delete
Am I missing something or was this just forgotten to implement into the model?
Please add the functions for the custom user status.
My working code inside UserModel.php looks like this:
/**
* @param $userId
* @param array $requestOptions
* @return ResponseInterface
*/
public function removeUserCustomStatus($userId, array $requestOptions)
{
return $this->client->delete(self::$endpoint . '/' . $userId . '/status/custom', $requestOptions);
}
/**
* @param $userId
* @param array $requestOptions
* @return ResponseInterface
*/
public function updateUserCustomStatus($userId, array $requestOptions)
{
return $this->client->put(self::$endpoint . '/' . $userId . '/status/custom', $requestOptions);
}
Fatal error: Declaration of Illuminate\Container\Container::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /vendor/illuminate/container/Container.php on line 169
php 7.4
"gnello/php-mattermost-driver": "^2.15"
Hello,
Thank you again for this repo.
I did the composer update today and got this error after the update:
Warning: Uncaught Error: Class 'Pimple\Container' not found in ...
$mm = new \Pimple\Container([
'driver' => [
'url' => '',
'login_id' => '',
'password' => '',
],
Pimple I installed composer require pimple/pimple
but I received a message that already in the library.
What could be the reason?
Thank you.
Now admin user can't set preferences for different users, because Preferences model constructor has userId parameter and it's instance cached then. So getPreferencesModel with different userId is simply ignored, which is not correct. I'm suggesting you to remove userId from constructor and move it to method parameters, or respect userId constructor parameter while caching model.
Could you update to support Guzzle ^7.2
Hi @gnello.
From version 5.28 of Mattermost API, it is optionally possible to permanently delete users and channels.
It is possible to add this feature to user and channel models?
This is my local patch to your package in order to achieve this feature with a boolean in deleteChannel
and deactivateUserAccount
calls:
diff --git a/src/Models/ChannelModel.php b/src/Models/ChannelModel.php
index c48f828..4c1211e 100644
--- a/src/Models/ChannelModel.php
+++ b/src/Models/ChannelModel.php
@@ -15,6 +15,7 @@
namespace Gnello\Mattermost\Models;
+use GuzzleHttp\RequestOptions;
use Psr\Http\Message\ResponseInterface;
/**
@@ -105,11 +106,20 @@ class ChannelModel extends AbstractModel
/**
* @param $channelId
+ * @param bool $permanent
* @return ResponseInterface
*/
- public function deleteChannel($channelId)
+ public function deleteChannel($channelId, bool $permanent = false)
{
- return $this->client->delete(self::$endpoint . '/' . $channelId);
+ $type = null;
+ $requestOptions = [];
+
+ if ($permanent) {
+ $requestOptions['permanent'] = true;
+ $type = RequestOptions::QUERY;
+ }
+
+ return $this->client->delete(self::$endpoint . '/' . $channelId, $requestOptions, $type);
}
/**
diff --git a/src/Models/UserModel.php b/src/Models/UserModel.php
index 6814713..9363216 100644
--- a/src/Models/UserModel.php
+++ b/src/Models/UserModel.php
@@ -126,11 +126,20 @@ class UserModel extends AbstractModel
/**
* @param $userId
+ * @param bool $permanent
* @return ResponseInterface
*/
- public function deactivateUserAccount($userId)
+ public function deactivateUserAccount($userId, bool $permanent = false)
{
- return $this->client->delete(self::$endpoint . '/' . $userId);
+ $type = null;
+ $requestOptions = [];
+
+ if ($permanent) {
+ $requestOptions['permanent'] = true;
+ $type = RequestOptions::QUERY;
+ }
+
+ return $this->client->delete(self::$endpoint . '/' . $userId, $requestOptions, $type);
}
/**
Thanks in advance!
I tried adding ^7.0 to composer.json, but spent two hours trying to get composer to update (with my forked repo) and lost patience. Is this all it needs?
"require": { "php": ">=7.0.0", "illuminate/support": "^5.0||^6.0||^7.0", "gnello/php-mattermost-driver": "^2.3" },
Hello,
would you be able to tag a new version of the library? (the 4.1 changes are working well for me now that the next release is out...)
thanks!
Hi
There is function in mettermost api Get all channels from all teams
but i can't find it in this repo.
https://api.mattermost.com/#tag/channels/operation/GetChannelsForUser
Hello,
This is great project thank you for your work.
Can we send post with file?
In Client.php it should be PUT instead of POST for saveUserPreferences
public function saveUserPreferences(array $requestOptions) { return $this->client->put(UserModel::$endpoint . '/' . $this->userId . '/preferences', $requestOptions); }
Hey!
Is there a plans for move to guzzlehttp/guzzle:7.x ?
Hello,
It was working great in my old project but I noticed a version issue in my new project. Is there any way to fix it?
Thank you.
Using version ^2.16 for gnello/php-mattermost-driver
./composer.json has been updated
Running composer update gnello/php-mattermost-driver
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires gnello/php-mattermost-driver ^2.16 -> satisfiable by gnello/php-mattermost-driver[v2.16.0].
- gnello/php-mattermost-driver v2.16.0 requires guzzlehttp/guzzle ^6.2 -> found guzzlehttp/guzzle[6.2.0, ..., 6.5.5] but it conflicts with your root composer.json require (^7.4).
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require gnello/php-mattermost-driver:*" to figure out if any version is installable, or "composer require gnello/php-mattermost-driver:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Don't you think ?
Thanks for this handy package. Pimple development has ended/is in maintenance mode, and I don't necessarily think this package need be aware of the dependency injection container per se. Open to decoupling from pimple/pimple
and refactoring to allow dependencies like the HTTP client be pulled in as a dependency from your DIC of choice?
I am the author of https://github.com/thePanz/MattermostClient
What about joining forces? :)
When using de mattermost driver it always returns a status code of 500.
The following code is used:
use Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver"=>[
"url"=>"https://mattermost-url.com",
"login_id"=>"username",
"password"=>"password",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$resp = $driver->getPostModel()->createPost([
'channel_id' => 'channel_id',
'messages' => 'message'
]);
$status = $resp->getStatusCode();
return $status;
Where status is always 500.
When I use the same credentials using postman it returns 200.
Hey, when I have 'url' => 'https://cloud.mydomain.com', then I get "HTTP ERROR 500" and without https:// I get "Everything is ok.NULL". Here's my code:
<?php
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
'driver' => [
'url' => 'cloud.mydomain.com',
'token' => 'token',
],
'guzzle' => [
//put here any options for Guzzle
]
]);
$driver = new Driver($container);
$result = $driver->authenticate();
//Add a new user
$result = $driver->getUserModel()->createUser([
'email' => '[email protected]',
'username' => 'atest100',
'password' => 'Asdc1523!Asdc1523!'
]);
$result = $driver->getChannelModel()->createChannel([
'name' => 'channel111',
'display_name' => 'Channel111',
'type' => 'O',
]);
if ($result->getStatusCode() == 200) {
echo "Everything is ok.";
var_dump(json_decode($result->getBody()));
} else {
echo "HTTP ERROR " . $result->getStatusCode();
}
?>
Hi,
Could you integrate the following three methods into the "TeamModel" class:
thank you
Pierre
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.