Browse Source
Merge pull request #874 from movim/feature/multi-identities
Merge pull request #874 from movim/feature/multi-identities
Feature/multi identitiespull/898/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 374 additions and 385 deletions
-
120app/Capability.php
-
4app/Conference.php
-
16app/Identity.php
-
175app/Info.php
-
9app/Post.php
-
2app/Presence.php
-
26app/Session.php
-
6app/User.php
-
1app/controllers/AccountController.php
-
1app/helpers/StringHelper.php
-
1app/helpers/UtilsHelper.php
-
2app/widgets/Account/Account.php
-
2app/widgets/Caps/Caps.php
-
3app/widgets/Chat/Chat.php
-
2app/widgets/Chats/_chats_item.tpl
-
1app/widgets/Communities/Communities.php
-
2app/widgets/CommunitiesServer/CommunitiesServer.php
-
15app/widgets/CommunitiesServers/CommunitiesServers.php
-
74app/widgets/CommunitiesServers/_communitiesservers.tpl
-
3app/widgets/CommunitiesServers/locales.ini
-
8app/widgets/CommunityAffiliations/CommunityAffiliations.php
-
12app/widgets/CommunityHeader/CommunityHeader.php
-
10app/widgets/ContactActions/_contactactions_drawer.tpl
-
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
-
4lib/moxl/src/Moxl/Utils.php
-
51lib/moxl/src/Moxl/Xec/Action/Disco/Items.php
-
38lib/moxl/src/Moxl/Xec/Action/Disco/Request.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/Create.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/Delete.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetAffiliations.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetConfig.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetItem.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetItems.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetItemsId.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/GetSubscriptions.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/PostDelete.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/PostPublish.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/SetAffiliations.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/SetConfig.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/SetSubscriptions.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/Subscribe.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/TestCreate.php
-
3lib/moxl/src/Moxl/Xec/Action/Pubsub/TestPostPublish.php
-
1lib/moxl/src/Moxl/Xec/Action/Pubsub/Unsubscribe.php
-
1lib/moxl/src/Moxl/Xec/Action/PubsubSubscription/Add.php
-
1lib/moxl/src/Moxl/Xec/Action/PubsubSubscription/Get.php
-
1lib/moxl/src/Moxl/Xec/Action/PubsubSubscription/Remove.php
-
28lib/moxl/src/Moxl/Xec/Payload/Caps.php
-
1src/Movim/ChatOwnState.php
-
1src/Movim/Controller/Base.php
-
3src/Movim/Daemon/Api.php
-
2src/Movim/Daemon/Session.php
-
1src/Movim/Widget/Base.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'); |
||||
|
} |
||||
|
} |
@ -1,30 +1,44 @@ |
|||||
<ul class="list flex third middle active"> |
|
||||
{loop="$servers"} |
|
||||
{if="!filter_var($value->server, FILTER_VALIDATE_EMAIL)"} |
|
||||
<li class="block |
|
||||
{if="$value->occupants == 0"}faded{/if}" |
|
||||
onclick="MovimUtils.redirect('{$c->route('community', $value->server)}')"> |
|
||||
<span class="primary icon bubble color {$value->server|stringToColor}"> |
|
||||
{$value->server|firstLetterCapitalize} |
|
||||
</span> |
|
||||
<p class="line" title="{$value->server} - {$value->name}"> |
|
||||
{$value->server} |
|
||||
<span class="second">{$value->name}</span> |
|
||||
</p> |
|
||||
<p>{$c->__('communities.counter', $value->occupants)}</p> |
|
||||
</li> |
|
||||
{/if} |
|
||||
{/loop} |
|
||||
<li class="block large"> |
|
||||
<span class="primary icon"> |
|
||||
<i class="material-icons">search</i> |
|
||||
</span> |
|
||||
<form> |
|
||||
<div> |
|
||||
<input placeholder="pubsub.server.com" onkeypress=" |
|
||||
if (event.keyCode == 13) { CommunitiesServers_ajaxDisco(this.value); return false; }" > |
|
||||
<label>{$c->__('communities.search_server')}</label> |
|
||||
</div> |
|
||||
</form> |
|
||||
</li> |
|
||||
</ul> |
|
||||
|
{if="$servers->isEmpty()"} |
||||
|
<ul class="thick"> |
||||
|
<div class="placeholder"> |
||||
|
<i class="material-icons">storage</i> |
||||
|
<h1>{$c->__('communitiesservers.empty_title')}</h1> |
||||
|
<h4>{$c->__('communitiesservers.empty_text')}</h4> |
||||
|
</li> |
||||
|
</ul> |
||||
|
{else} |
||||
|
<ul class="list flex third middle active"> |
||||
|
{loop="$servers"} |
||||
|
{if="!filter_var($value->server, FILTER_VALIDATE_EMAIL)"} |
||||
|
<li class="block |
||||
|
{if="$value->occupants == 0"}faded{/if}" |
||||
|
onclick="MovimUtils.redirect('{$c->route('community', $value->server)}')"> |
||||
|
<span class="primary icon bubble color {$value->server|stringToColor}"> |
||||
|
{$value->server|firstLetterCapitalize} |
||||
|
</span> |
||||
|
<p class="line" title="{$value->server} - {$value->name}"> |
||||
|
{$value->server} |
||||
|
<span class="second">{$value->name}</span> |
||||
|
</p> |
||||
|
<p>{$c->__('communities.counter', $value->occupants)}</p> |
||||
|
</li> |
||||
|
{/if} |
||||
|
{/loop} |
||||
|
</ul> |
||||
|
{/if} |
||||
|
{if="!$restrict"} |
||||
|
<ul class="list middle"> |
||||
|
<li class="block large"> |
||||
|
<span class="primary icon"> |
||||
|
<i class="material-icons">search</i> |
||||
|
</span> |
||||
|
<form> |
||||
|
<div> |
||||
|
<input placeholder="pubsub.server.com" onkeypress=" |
||||
|
if (event.keyCode == 13) { CommunitiesServers_ajaxDisco(this.value); return false; }" > |
||||
|
<label>{$c->__('communities.search_server')}</label> |
||||
|
</div> |
||||
|
</form> |
||||
|
</li> |
||||
|
</ul> |
||||
|
{/if} |
@ -0,0 +1,3 @@ |
|||||
|
[communitiesservers] |
||||
|
empty_title = No Communities Servers yet… |
||||
|
empty_text = "It seems that we can't find any communities for the moment" |
@ -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