Browse Source

Simply copy the sticker to the cache when sending it

Prevent infinite loop when missing local cache
pull/436/head
Timothée Jaussoin 8 years ago
parent
commit
93943d6a1d
  1. 3
      app/widgets/Chat/Chat.php
  2. 7
      app/widgets/Stickers/Stickers.php

3
app/widgets/Chat/Chat.php

@ -686,7 +686,8 @@ class Chat extends \Movim\Widget\Base
$sticker = $p->get($message->sticker, false, false, 'png');
$stickerSize = $p->getSize();
if ($sticker == false) {
if ($sticker == false
&& $message->jidfrom != $message->session) {
$r = new Request;
$r->setTo($message->jidfrom)
->setResource($message->resource)

7
app/widgets/Stickers/Stickers.php

@ -51,14 +51,9 @@ class Stickers extends \Movim\Widget\Base
if(!file_exists($filepath)) return;
// We get the base64
$base64 = base64_encode(file_get_contents($filepath));
// Caching the picture
if(!file_exists(CACHE_PATH.md5($key).'.png')) {
$p = new Picture;
$p->fromBase($base64);
$p->set($key, 'png');
copy($filepath, CACHE_PATH.md5($key).'.png');
}
// Creating a message

Loading…
Cancel
Save