29 changed files with 329 additions and 329 deletions
-
120app/Capability.php
-
4app/Conference.php
-
16app/Identity.php
-
196app/Info.php
-
9app/Post.php
-
2app/Presence.php
-
26app/Session.php
-
6app/User.php
-
13app/helpers/UtilsHelper.php
-
2app/widgets/Account/Account.php
-
2app/widgets/Caps/Caps.php
-
2app/widgets/Chat/Chat.php
-
2app/widgets/CommunitiesServer/CommunitiesServer.php
-
12app/widgets/CommunitiesServers/CommunitiesServers.php
-
4app/widgets/CommunityAffiliations/CommunityAffiliations.php
-
12app/widgets/CommunityHeader/CommunityHeader.php
-
4app/widgets/Post/Post.php
-
2app/widgets/PublishBrief/PublishBrief.php
-
18app/widgets/Rooms/Rooms.php
-
5app/widgets/Rooms/_rooms_add.tpl
-
2app/widgets/Rooms/rooms.js
-
4app/widgets/Search/Search.php
-
2app/widgets/Statistics/Statistics.php
-
2app/widgets/Upload/Upload.php
-
1database/migrations/20190324190611_create_reactions_table.php
-
73database/migrations/20191017214225_create_identities_table.php
-
51lib/moxl/src/Moxl/Xec/Action/Disco/Items.php
-
38lib/moxl/src/Moxl/Xec/Action/Disco/Request.php
-
28lib/moxl/src/Moxl/Xec/Payload/Caps.php
@ -1,120 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Capability extends Model |
|||
{ |
|||
protected $primaryKey = 'node'; |
|||
protected $fillable = ['features']; |
|||
public $incrementing = false; |
|||
|
|||
public function save(array $options = []) |
|||
{ |
|||
try { |
|||
parent::save($options); |
|||
} catch (\Exception $e) { |
|||
/* |
|||
* When an capability is received by two accounts simultaenously |
|||
*/ |
|||
} |
|||
} |
|||
|
|||
public function set($query, $node = false) |
|||
{ |
|||
if (!$node) { |
|||
$this->node = (string)$query->query->attributes()->node; |
|||
} else { |
|||
$this->node = $node; |
|||
} |
|||
|
|||
if (isset($query->query)) { |
|||
foreach ($query->query->identity as $i) { |
|||
if ($i->attributes()) { |
|||
$this->category = (string)$i->attributes()->category; |
|||
$this->type = (string)$i->attributes()->type; |
|||
|
|||
if ($i->attributes()->name) { |
|||
$this->name = (string)$i->attributes()->name; |
|||
} else { |
|||
$this->name = $this->node; |
|||
} |
|||
} |
|||
} |
|||
|
|||
$fet = []; |
|||
foreach ($query->query->feature as $f) { |
|||
array_push($fet, (string)$f->attributes()->var); |
|||
} |
|||
|
|||
$this->setFeaturesAttribute($fet); |
|||
} |
|||
} |
|||
|
|||
public function getPubsubRoles() |
|||
{ |
|||
$roles = ['owner' => __('affiliation.owner'), 'none' => __('affiliation.no-aff')]; |
|||
|
|||
foreach ($this->getFeaturesAttribute() as $feature) { |
|||
preg_match("/http:\/\/jabber.org\/protocol\/pubsub#(.*)-affiliation$/", $feature, $matches); |
|||
if (!empty($matches)) { |
|||
$roles[$matches[1]] = __('affiliation.' . $matches[1]); |
|||
} |
|||
} |
|||
|
|||
return $roles; |
|||
} |
|||
|
|||
public function isPubsub() |
|||
{ |
|||
return (in_array('http://jabber.org/protocol/pubsub#persistent-items', $this->getFeaturesAttribute())); |
|||
} |
|||
|
|||
public function isJingle() |
|||
{ |
|||
return (in_array('urn:xmpp:jingle:1', $this->getFeaturesAttribute())); |
|||
} |
|||
|
|||
public function isMAM() |
|||
{ |
|||
return (in_array('urn:xmpp:mam:1', $this->getFeaturesAttribute())); |
|||
} |
|||
|
|||
public function isMAM2() |
|||
{ |
|||
return (in_array('urn:xmpp:mam:2', $this->getFeaturesAttribute())); |
|||
} |
|||
|
|||
public function getDeviceIcon() |
|||
{ |
|||
if (in_array($this->type, ['handheld', 'phone'])) { |
|||
return 'smartphone'; |
|||
} |
|||
if ($this->type == 'bot') { |
|||
return 'memory'; |
|||
} |
|||
if ($this->type == 'console') { |
|||
return 'video_label'; |
|||
} |
|||
if ($this->type == 'web') { |
|||
if ($this->name == 'Movim') { |
|||
return 'cloud_queue'; |
|||
} |
|||
|
|||
return 'language'; |
|||
} |
|||
|
|||
return 'desktop_windows'; |
|||
} |
|||
|
|||
public function getFeaturesAttribute() |
|||
{ |
|||
return unserialize($this->attributes['features']); |
|||
} |
|||
|
|||
public function setFeaturesAttribute($features) |
|||
{ |
|||
$this->attributes['features'] = serialize($features); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App; |
|||
|
|||
use Movim\Model; |
|||
|
|||
class Identity extends Model |
|||
{ |
|||
protected $primaryKey = ['info_id', 'category', 'type']; |
|||
public $incrementing = false; |
|||
|
|||
public function info() |
|||
{ |
|||
return $this->belongsTo('App\Info'); |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
<?php |
|||
|
|||
use Movim\Migration; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Database\Capsule\Manager as DB; |
|||
|
|||
class CreateIdentitiesTable extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->schema->table('infos', function (Blueprint $table) { |
|||
$table->dropPrimary('infos_pkey'); |
|||
}); |
|||
|
|||
DB::table('infos')->truncate(); |
|||
|
|||
$this->schema->table('infos', function (Blueprint $table) { |
|||
$table->increments('id'); |
|||
$table->dropColumn('category'); |
|||
$table->dropColumn('type'); |
|||
$table->unique(['server', 'node']); |
|||
$table->text('features')->nullable(); |
|||
$table->string('server')->nullable()->change(); |
|||
}); |
|||
|
|||
$this->schema->create('identities', function (Blueprint $table) { |
|||
$table->integer('info_id')->unsigned(); |
|||
$table->string('category'); |
|||
$table->string('type'); |
|||
$table->timestamps(); |
|||
|
|||
$table->foreign('info_id')->references('id') |
|||
->on('infos')->onDelete('cascade'); |
|||
|
|||
$table->index('category'); |
|||
$table->index('type'); |
|||
|
|||
$table->primary(['info_id', 'category', 'type']); |
|||
}); |
|||
|
|||
$this->schema->drop('capabilities'); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->schema->drop('identities'); |
|||
|
|||
DB::table('infos')->truncate(); |
|||
|
|||
$this->schema->table('infos', function (Blueprint $table) { |
|||
$table->dropColumn('id'); |
|||
$table->dropColumn('features'); |
|||
$table->dropUnique('infos_server_node_unique'); |
|||
$table->string('category', 16); |
|||
$table->string('type', 16)->nullable(); |
|||
$table->primary(['server', 'node']); |
|||
$table->string('server')->nullable(false)->change(); |
|||
}); |
|||
|
|||
$this->schema->create('capabilities', function (Blueprint $table) { |
|||
$table->string('node', 256); |
|||
$table->string('category', 16); |
|||
$table->string('type', 16); |
|||
$table->string('name', 128); |
|||
$table->text('features'); |
|||
$table->timestamps(); |
|||
|
|||
$table->primary('node'); |
|||
$table->index('category'); |
|||
$table->index('type'); |
|||
}); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue