Giter VIP home page Giter VIP logo

php-mattermost-driver's People

Contributors

aizeleouf avatar alexmorbo avatar anx-dwuggenig avatar brettmc avatar brunospy avatar dependabot[bot] avatar gnello avatar jelly avatar matak avatar prixone avatar scottliddick avatar sheasollars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-mattermost-driver's Issues

Laravel 7 support?

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" },

Wrong request type for saveUserPreferences

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); }

Can't use search in channel !

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 :

return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/search', $requestOptions);

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 !

Decouple from Pimple

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?

Add optional permanent=true to user and channel delete

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!

" Class 'Pimple\Container' not found"

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.

Can not upload file

$result = $driver->getFileModel()->uploadFile([
'channel_id' => $request->channel_id,
'filename' => $name,
'files' => $file
]);

I can not upload file when following the readme
.
This is my error

throw

tag new version

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!

With https:// in the beginning 500 error and without nothing happens

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();
}
?>

Fatal error: Declaration of Illuminate

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"

Guzzle

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.

Endpoint for custom user status

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);
}

Preferences model are locked to single user because of model caching

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.

Methods to manage icons

Hi,

Could you integrate the following three methods into the "TeamModel" class:

  • GET /teams/{team_id}/image
  • POST /teams/{team_id}/image
  • DELETE /teams/{team_id}/image

thank you
Pierre

Returns 500

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.