Browse Source

Improve the contact block/unblock flows

Add a me() utils
pull/1456/head
Timothée Jaussoin 4 months ago
parent
commit
63d3e0b562
  1. 2
      CHANGELOG.md
  2. 2
      app/Bundle.php
  3. 4
      app/BundleCapabilityResolver.php
  4. 16
      app/Conference.php
  5. 4
      app/Contact.php
  6. 2
      app/Controllers/NewsController.php
  7. 8
      app/Helpers/UtilsHelper.php
  8. 4
      app/Info.php
  9. 32
      app/Message.php
  10. 2
      app/MujiCall.php
  11. 4
      app/MujiCallParticipant.php
  12. 31
      app/Post.php
  13. 4
      app/Presence.php
  14. 2
      app/Session.php
  15. 4
      app/Views/admin.tpl
  16. 6
      app/Views/chat.tpl
  17. 4
      app/Views/community.tpl
  18. 8
      app/Views/configuration.tpl
  19. 4
      app/Views/contact.tpl
  20. 4
      app/Views/explore.tpl
  21. 4
      app/Views/help.tpl
  22. 4
      app/Views/news.tpl
  23. 4
      app/Views/page.tpl
  24. 2
      app/Views/post.tpl
  25. 2
      app/Views/publish.tpl
  26. 4
      app/Views/subscriptions.tpl
  27. 2
      app/Views/tag.tpl
  28. 2
      app/Widgets/AdminMain/AdminMain.php
  29. 4
      app/Widgets/Blocked/_blocked_list.tpl
  30. 2
      app/Widgets/Blocked/blocked.tpl
  31. 4
      app/Widgets/Chat/_chat_header.tpl
  32. 4
      app/Widgets/ChatActions/ChatActions.php
  33. 8
      app/Widgets/Chats/Chats.php
  34. 16
      app/Widgets/ContactActions/ContactActions.php
  35. 42
      app/Widgets/ContactActions/_contactactions_drawer.tpl
  36. 3
      app/Widgets/ContactHeader/_contactheader.tpl
  37. 1
      app/Widgets/NewsNav/NewsNav.php
  38. 6
      app/Widgets/Notif/Notif.php
  39. 2
      app/Widgets/RoomsUtils/RoomsUtils.php
  40. 2
      src/Movim/ChatStates.php
  41. 2
      src/Movim/ChatroomPings.php
  42. 2
      src/Movim/Librairies/SDPtoJingle.php
  43. 2
      src/Movim/Librairies/XMPPtoForm.php
  44. 2
      src/Movim/Widget/Base.php
  45. 2
      src/Moxl/API.php
  46. 2
      src/Moxl/Stanza/Presence.php
  47. 2
      src/Moxl/Xec/Action/Avatar/Set.php
  48. 2
      src/Moxl/Xec/Action/BOB/Request.php
  49. 4
      src/Moxl/Xec/Action/Blocking/Block.php
  50. 6
      src/Moxl/Xec/Action/Blocking/Request.php
  51. 4
      src/Moxl/Xec/Action/Blocking/Unblock.php
  52. 2
      src/Moxl/Xec/Action/Bookmark2/Delete.php
  53. 4
      src/Moxl/Xec/Action/Bookmark2/Get.php
  54. 2
      src/Moxl/Xec/Action/Bookmark2/Set.php
  55. 2
      src/Moxl/Xec/Action/Jingle/SessionTerminate.php
  56. 2
      src/Moxl/Xec/Action/MAM/Get.php
  57. 8
      src/Moxl/Xec/Action/OMEMO/DeleteBundle.php
  58. 2
      src/Moxl/Xec/Action/OMEMO/GetBundle.php
  59. 2
      src/Moxl/Xec/Action/OMEMO/GetDeviceList.php
  60. 4
      src/Moxl/Xec/Action/Presence/Muc.php
  61. 2
      src/Moxl/Xec/Action/PubsubSubscription/Remove.php
  62. 2
      src/Moxl/Xec/Action/Roster/RemoveItem.php
  63. 2
      src/Moxl/Xec/Action/Roster/UpdateItem.php
  64. 2
      src/Moxl/Xec/Action/Session/Bind.php
  65. 2
      src/Moxl/Xec/Action/Session/Start.php
  66. 2
      src/Moxl/Xec/Action/Vcard4/Set.php
  67. 4
      src/Moxl/Xec/Payload/Blocked.php
  68. 6
      src/Moxl/Xec/Payload/Bookmark2.php
  69. 2
      src/Moxl/Xec/Payload/CallInviteAccept.php
  70. 2
      src/Moxl/Xec/Payload/CallInviteLeft.php
  71. 2
      src/Moxl/Xec/Payload/CallInvitePropose.php
  72. 2
      src/Moxl/Xec/Payload/CallInviteRetract.php
  73. 4
      src/Moxl/Xec/Payload/Carbons.php
  74. 6
      src/Moxl/Xec/Payload/Displayed.php
  75. 2
      src/Moxl/Xec/Payload/Location.php
  76. 2
      src/Moxl/Xec/Payload/Message.php
  77. 2
      src/Moxl/Xec/Payload/Moderated.php
  78. 2
      src/Moxl/Xec/Payload/OMEMODevices.php
  79. 6
      src/Moxl/Xec/Payload/Presence.php
  80. 4
      src/Moxl/Xec/Payload/ReceiptAck.php
  81. 2
      src/Moxl/Xec/Payload/ReceiptRequest.php
  82. 2
      src/Moxl/Xec/Payload/Retracted.php
  83. 2
      src/Moxl/Xec/Payload/Roster.php
  84. 2
      src/Moxl/Xec/Payload/SASL2Success.php
  85. 2
      src/Moxl/Xec/Payload/SASLSuccess.php
  86. 2
      src/Moxl/Xec/Payload/SessionBind.php
  87. 4
      src/Moxl/Xec/Payload/Unblocked.php

2
CHANGELOG.md

@ -6,6 +6,8 @@ v0.31.1 (master)
* Add a copy external link button on the Posts
* Improve the Communities discovery flow when visiting a server
* Add a MAMEarliest table to keep track of the earliest message when requesting MAM
* Improve the contact block/unblock flows
* Add a me() utils
v0.31
---------------------------

2
app/Bundle.php

@ -17,7 +17,7 @@ class Bundle extends Model
public function set(string $jid, string $bundleId, $bundle)
{
$this->user_id = \App\User::me()->id;
$this->user_id = me()->id;
$this->jid = $jid;
$this->bundleid = $bundleId;

4
app/BundleCapabilityResolver.php

@ -26,7 +26,7 @@ class BundleCapabilityResolver
public function load()
{
$this->_bundles = Bundle::where('user_id', \App\User::me()->id)
$this->_bundles = Bundle::where('user_id', me()->id)
->whereNull('node')
->select('jid', 'bundleid')
->get()
@ -42,7 +42,7 @@ class BundleCapabilityResolver
->first();
if ($presence && $presence->capability) {
Bundle::where('user_id', \App\User::me()->id)
Bundle::where('user_id', me()->id)
->whereNull('node')
->where('jid', $message->jidfrom)
->where('bundleid', $message->bundleid)

16
app/Conference.php

@ -55,13 +55,13 @@ class Conference extends Model
public function otherPresences()
{
return $this->presences()->where('mucjid', '!=', \App\User::me()->id);
return $this->presences()->where('mucjid', '!=', me()->id);
}
public function unreads()
{
return $this->hasMany('App\Message', 'jidfrom', 'conference')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('type', 'groupchat')
->whereNull('subject')
->where('seen', false);
@ -70,7 +70,7 @@ class Conference extends Model
public function quoted()
{
return $this->hasMany('App\Message', 'jidfrom', 'conference')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('type', 'groupchat')
->whereNull('subject')
->where('quoted', true)
@ -81,7 +81,7 @@ class Conference extends Model
{
return $this->hasOne('App\Presence', ['jid', 'session_id'], ['conference', 'session_id'])
->where('value', '<', 5)
->where('mucjid', \App\User::me()->id);
->where('mucjid', me()->id);
}
public function members()
@ -103,7 +103,7 @@ class Conference extends Model
public function pictures()
{
return $this->hasMany('App\Message', 'jidfrom', 'conference')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('type', 'groupchat')
->where('picture', true)
->where('retracted', false)
@ -113,7 +113,7 @@ class Conference extends Model
public function links()
{
return $this->hasMany('App\Message', 'jidfrom', 'conference')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('type', 'groupchat')
->whereNotNull('urlid')
->where('picture', false)
@ -128,7 +128,7 @@ class Conference extends Model
$query->where('node', function ($query) {
$query->select('node')
->from('presences')
->where('session_id', \App\User::me()->session->id)
->where('session_id', me()->session->id)
->whereColumn('jid', 'infos.server')
->where('resource', '')
->take(1);
@ -211,7 +211,7 @@ class Conference extends Model
public function getSubjectAttribute()
{
$subject = \App\User::me()
$subject = me()
->messages()
->jid($this->conference)
->whereNotNull('subject')

4
app/Contact.php

@ -393,7 +393,7 @@ class Contact extends Model
public function isBlocked(): bool
{
return \App\User::me()->hasBlocked($this->id, true);
return me()->hasBlocked($this->id, true);
}
public function isEmpty(): bool
@ -438,7 +438,7 @@ class Contact extends Model
public function isMe(): bool
{
return ($this->id == \App\User::me()->id);
return ($this->id == me()->id);
}
public function isPublic(): bool

2
app/Controllers/NewsController.php

@ -15,7 +15,7 @@ class NewsController extends Base
{
$this->page->setTitle(__('page.news'));
if (!\App\User::me()->hasPubsub()) {
if (!me()->hasPubsub()) {
$this->redirect('contact');
}
}

8
app/Helpers/UtilsHelper.php

@ -10,6 +10,14 @@ use React\Http\Message\Response;
use React\Promise\Promise;
use React\Promise\PromiseInterface;
/**
* Me
*/
function me(bool $reload = false)
{
return \App\User::me($reload);
}
/**
* Log an error
*/

4
app/Info.php

@ -64,7 +64,7 @@ class Info extends Model
if ($configuration->restrictsuggestions) {
$query->whereIn('server', function ($query) {
$host = \App\User::me()->session->host;
$host = me()->session->host;
$query->select('server')
->from('infos')
->where('server', 'like', '%.' . $host);
@ -205,7 +205,7 @@ class Info extends Model
*/
public function getPresenceAttribute()
{
return \App\User::me()->session->presences()
return me()->session->presences()
->where('jid', $this->attributes['server'])
->first();
}

32
app/Message.php

@ -44,7 +44,7 @@ class Message extends Model
static::saved(function (Message $message) {
if ($message->messageFiles != null && $message->messageFiles->isNotEmpty()) {
$mid = Message::where('id', $message->id)
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('jidfrom', $message->jidfrom)
->first()
->mid;
@ -92,18 +92,18 @@ class Message extends Model
public function scopeJid($query, string $jid)
{
$jidFromToMessages = DB::table('messages')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('jidfrom', $jid)
->unionAll(
DB::table('messages')
->where('user_id', \App\User::me()->id)
->where('user_id', me()->id)
->where('jidto', $jid)
);
return $query->select('*')->from(
$jidFromToMessages,
'messages'
)->where('user_id', \App\User::me()->id);
)->where('user_id', me()->id);
}
public function reactions()
@ -161,24 +161,24 @@ class Message extends Model
&& $stanza->attributes()->xmlns == 'urn:xmpp:mam:2'
) {
return self::firstOrNew([
'user_id' => \App\User::me()->id,
'user_id' => me()->id,
'stanzaid' => (string)$stanza->attributes()->id,
'jidfrom' => baseJid((string)$stanza->forwarded->message->attributes()->from)
]);
} elseif (
$stanza->{'stanza-id'} && $stanza->{'stanza-id'}->attributes()->id
&& ($stanza->{'stanza-id'}->attributes()->by == $jidfrom
|| $stanza->{'stanza-id'}->attributes()->by == \App\User::me()->id
|| $stanza->{'stanza-id'}->attributes()->by == me()->id
)
) {
return self::firstOrNew([
'user_id' => \App\User::me()->id,
'user_id' => me()->id,
'stanzaid' => (string)$stanza->{'stanza-id'}->attributes()->id,
'jidfrom' => $jidfrom
]);
} else {
$message = new Message;
$message->user_id = \App\User::me()->id;
$message->user_id = me()->id;
$message->id = 'm_' . generateUUID();
$message->jidfrom = $jidfrom;
return $message;
@ -191,23 +191,23 @@ class Message extends Model
if ($muc) {
// Resolve the current presence
$presence = \App\User::me()->session->presences()
$presence = me()->session->presences()
->where('jid', $to)
->where('muc', true)
->where('mucjid', \App\User::me()->id)
->where('mucjid', me()->id)
->first();
if ($presence) {
$m = \App\User::me()->messages()
$m = me()->messages()
->where('type', 'groupchat')
->where('jidfrom', $to)
->where('jidto', \App\User::me()->id)
->where('jidto', me()->id)
->where('resource', $presence->resource)
->orderBy('published', 'desc')
->first();
}
} else {
$m = \App\User::me()->messages()
$m = me()->messages()
->where('jidto', $to)
->orderBy('published', 'desc')
->first();
@ -225,7 +225,7 @@ class Message extends Model
public static function eventMessageFactory(string $type, string $from, string $thread): Message
{
$userid = \App\User::me()->id;
$userid = me()->id;
$message = new \App\Message;
$message->user_id = $userid;
$message->id = 'm_' . generateUUID();
@ -258,7 +258,7 @@ class Message extends Model
$jidTo = explodeJid((string)$stanza->attributes()->to);
$jidFrom = explodeJid((string)$stanza->attributes()->from);
$this->user_id = \App\User::me()->id;
$this->user_id = me()->id;
if (!$this->id) {
$this->id = 'm_' . generateUUID();
@ -313,7 +313,7 @@ class Message extends Model
&& $stanza->{'stanza-id'}->attributes()->id
&& (string)$stanza->{'stanza-id'}->attributes()->xmlns == 'urn:xmpp:sid:0'
&& ($stanza->{'stanza-id'}->attributes()->by == $this->jidfrom
|| $stanza->{'stanza-id'}->attributes()->by == \App\User::me()->id
|| $stanza->{'stanza-id'}->attributes()->by == me()->id
)
) {
if ($this->isMuc()) {

2
app/MujiCall.php

@ -41,7 +41,7 @@ class MujiCall extends Model
{
return $this->hasOne('App\Presence', ['jid', 'session_id'], ['muc', 'session_id'])
->where('value', '<', 5)
->where('mucjid', \App\User::me()->id);
->where('mucjid', me()->id);
}
public function participants()

4
app/MujiCallParticipant.php

@ -32,12 +32,12 @@ class MujiCallParticipant extends Model
$jid = explodeJid($this->jid);
if ($jid['resource'] == null) {
return $this->jid == \App\User::me()->id;
return $this->jid == me()->id;
}
$presence = Presence::where('jid', $jid['jid'])->where('resource', $jid['resource'])->first();
return $presence && $presence->mucjid == \App\User::me()->id;
return $presence && $presence->mucjid == me()->id;
}
public function getNameAttribute()

31
app/Post.php

@ -74,7 +74,7 @@ class Post extends Model
public function userAffiliation()
{
return $this->hasOne('App\Affiliation', ['server', 'node'], ['server', 'node'])
->where('jid', \App\User::me()->id);
->where('jid', me()->id);
}
public function userViews()
@ -84,7 +84,7 @@ class Post extends Model
public function myViews()
{
return $this->userViews()->where('user_id', \App\User::me()->id);
return $this->userViews()->where('user_id', me()->id);
}
public function likes()
@ -215,7 +215,7 @@ class Post extends Model
if ($configuration->restrictsuggestions) {
$query->whereIn('id', function ($query) {
$host = \App\User::me()->session->host;
$host = me()->session->host;
$query->select('id')
->from('posts')
->where('server', 'like', '%.' . $host)
@ -224,11 +224,20 @@ class Post extends Model
}
}
public function scopeRestrictReported($query)
{
$query->whereNotIn('aid', function ($query) {
$query->select('reported_id')
->from('reported_user')
->where('user_id', me()->id);
});
}
public function scopeRestrictNSFW($query)
{
$query->where('nsfw', false);
if (\App\User::me()->nsfw) {
if (me()->nsfw) {
$query->orWhere('nsfw', true);
}
}
@ -272,7 +281,7 @@ class Post extends Model
return $query->unionAll(
DB::table('posts')
->where('node', $node)
->where('server', \App\User::me()->id)
->where('server', me()->id)
);
}
@ -288,12 +297,12 @@ class Post extends Model
->whereIn('server', function ($query) {
$query->select('server')
->from('subscriptions')
->where('jid', \App\User::me()->id);
->where('jid', me()->id);
})
->whereIn('node', function ($query) {
$query->select('node')
->from('subscriptions')
->where('jid', \App\User::me()->id);
->where('jid', me()->id);
})
);
}
@ -793,11 +802,11 @@ class Post extends Model
public function isMine($force = false): bool
{
if ($force) {
return ($this->aid == \App\User::me()->id);
return ($this->aid == me()->id);
}
return ($this->aid == \App\User::me()->id
|| $this->server == \App\User::me()->id);
return ($this->aid == me()->id
|| $this->server == me()->id);
}
public function isMicroblog(): bool
@ -888,7 +897,7 @@ class Post extends Model
public function isLiked()
{
return ($this->likes()->where('aid', \App\User::me()->id)->count() > 0);
return ($this->likes()->where('aid', me()->id)->count() > 0);
}
public function isRecycled()

4
app/Presence.php

@ -146,7 +146,7 @@ class Presence extends Model
$session = Session::instance();
if ($session->get(Muc::$mucId . (string)$stanza->attributes()->from)) {
$this->mucjid = \App\User::me()->id;
$this->mucjid = me()->id;
}
if (!isset($c->item)) {
@ -154,7 +154,7 @@ class Presence extends Model
}
if (!empty($c->xpath("//status[@code='110']"))) {
$this->mucjid = \App\User::me()->id;
$this->mucjid = me()->id;
} elseif ($c->item->attributes()->jid) {
$jid = explodeJid((string)$c->item->attributes()->jid);
$this->mucjid = $jid['jid'];

2
app/Session.php

@ -108,7 +108,7 @@ class Session extends Model
$configuration = Configuration::get();
if ($configuration->restrictsuggestions) {
$host = \App\User::me()->session->host;
$host = me()->session->host;
$where .= ' where server like \'%.' . $host . '\'';
}

4
app/Views/admin.tpl

@ -24,7 +24,7 @@
</ul>
</header>
<?php if (\App\User::me()->admin) { ?>
<?php if (me()->admin) { ?>
<?php $this->widget('Tabs');?>
<ul class="tabs" id="navtabs"></ul>
@ -35,6 +35,6 @@
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

6
app/Views/chat.tpl

@ -4,7 +4,7 @@
<?php $this->widget('SendTo');?>
<?php $this->widget('ContactActions');?>
<?php $this->widget('AdHoc');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<nav>
<?php $this->widget('Presence');?>
@ -21,7 +21,7 @@
<a class="button action color" onclick="Search_ajaxRequest(true)">
<i class="material-symbols">add</i>
</a>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Stories');?>
<?php } ?>
<?php $this->widget('Chats');?>
@ -32,7 +32,7 @@
<?php $this->widget('Dictaphone');?>
<?php $this->widget('Snap');?>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php $this->widget('StoriesViewer');?>
<?php } ?>

4
app/Views/community.tpl

@ -3,7 +3,7 @@
<?php $this->widget('Upload'); ?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php $this->widget('PostActions');?>
<nav>
@ -58,6 +58,6 @@
<?php } ?>
</main>
<?php if (isLogged() && \App\User::me()->hasPubsub()) { ?>
<?php if (isLogged() && me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

8
app/Views/configuration.tpl

@ -1,7 +1,7 @@
<?php $this->widget('Search');?>
<?php $this->widget('Onboarding');?>
<?php $this->widget('Notifications');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<nav>
<?php $this->widget('Presence');?>
@ -28,18 +28,18 @@
<?php $this->widget('Tabs');?>
<ul class="tabs" id="navtabs"></ul>
<?php $this->widget('Vcard4');?>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Avatar');?>
<?php $this->widget('Config');?>
<?php } ?>
<?php $this->widget('Account');?>
<?php $this->widget('EmojisConfig');?>
<?php $this->widget('NotificationConfig');?>
<?php $this->widget('AdHoc', ['to' => \App\User::me()->session->host]);?>
<?php $this->widget('AdHoc', ['to' => me()->session->host]);?>
<?php $this->widget('Blocked');?>
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

4
app/Views/contact.tpl

@ -5,7 +5,7 @@
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php $this->widget('Tabs');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<nav>
<?php $this->widget('Presence');?>
@ -25,7 +25,7 @@
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php $this->widget('StoriesViewer');?>
<?php } ?>

4
app/Views/explore.tpl

@ -2,7 +2,7 @@
<?php $this->widget('Upload'); ?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php $this->widget('PostActions');?>
@ -48,6 +48,6 @@
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

4
app/Views/help.tpl

@ -1,6 +1,6 @@
<?php $this->widget('Search');?>
<?php $this->widget('Notifications');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<nav>
<?php $this->widget('Presence');?>
@ -30,6 +30,6 @@
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

4
app/Views/news.tpl

@ -3,7 +3,7 @@
<?php $this->widget('Onboarding');?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php $this->widget('PostActions');?>
@ -26,6 +26,6 @@
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

4
app/Views/page.tpl

@ -4,7 +4,7 @@
<meta charset="utf-8" />
<title><%title%></title>
<meta name="theme-color" media="(prefers-color-scheme: light)" content="<?php if (!$this->public && isLogged() && \App\User::me()->nightmode) { ?>rgb(25, 32, 40)<?php } else { ?>rgb(238, 238, 238)<?php } ?>" />
<meta name="theme-color" media="(prefers-color-scheme: light)" content="<?php if (!$this->public && isLogged() && me()->nightmode) { ?>rgb(25, 32, 40)<?php } else { ?>rgb(238, 238, 238)<?php } ?>" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="rgb(25, 32, 40)" />
<%meta%>
@ -26,7 +26,7 @@
<%scripts%>
</head>
<body dir="<%dir%>"
class="<?php if (!$this->public && isLogged() && \App\User::me()->nightmode) { ?>nightmode<?php } ?>">
class="<?php if (!$this->public && isLogged() && me()->nightmode) { ?>nightmode<?php } ?>">
<%common%>
<%content%>
</body>

2
app/Views/post.tpl

@ -3,7 +3,7 @@
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php $this->widget('Tabs');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php $this->widget('ContactActions');?>
<?php $this->widget('AdHoc');?>

2
app/Views/publish.tpl

@ -1,7 +1,7 @@
<?php $this->widget('Search');?>
<?php $this->widget('Upload'); ?>
<?php $this->widget('Notifications');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<nav>
<?php $this->widget('Presence');?>

4
app/Views/subscriptions.tpl

@ -21,12 +21,12 @@
</li>
</ul>
</header>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('CommunitySubscriptions'); ?>
<?php } ?>
</div>
</main>
<?php if (\App\User::me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

2
app/Views/tag.tpl

@ -2,7 +2,7 @@
<?php $this->widget('Search');?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
<?php if(\App\User::me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
<?php $this->widget('PostActions');?>

2
app/Widgets/AdminMain/AdminMain.php

@ -13,7 +13,7 @@ class AdminMain extends \Movim\Widget\Base
$configuration = Configuration::get();
if (isset($form) && !empty($form) && isset($form['adminform']) && \App\User::me()->admin) {
if (isset($form) && !empty($form) && isset($form['adminform']) && me()->admin) {
$form['disableregistration'] = (isset($form['disableregistration']));
$form['restrictsuggestions'] = (isset($form['restrictsuggestions']));
$form['chatonly'] = (isset($form['chatonly']));

4
app/Widgets/Blocked/_blocked_list.tpl

@ -1,5 +1,5 @@
{loop="$list"}<li id="blocked-{$value->id|cleanupId}">
<span class="primary icon gray">
{loop="$list"}<li class="block" id="blocked-{$value->id|cleanupId}">
<span class="control icon active" onclick="MovimUtils.reload('{$c->route('contact', $value->id)}');">
<i class="material-symbols">person</i>
</span>
<span class="control icon active divided" onclick="Blocked_ajaxUnblock('{$value->id|echapJS}')">

2
app/Widgets/Blocked/blocked.tpl

@ -10,7 +10,7 @@
</div>
</li>
</ul>
<ul class="list thin" id="blocked_widget_list"></ul>
<ul class="list card thin flex shadow" id="blocked_widget_list"></ul>
<div class="placeholder">
<i class="material-symbols">block</i>
<h4>{$c->__('blocked.placeholder')}</h4>

4
app/Widgets/Chat/_chat_header.tpl

@ -315,6 +315,10 @@
{else}
{$contact->truename}
{/if}
{if="$contact->isBlocked()"}
<span class="tag color red">{$c->__('blocked.title')}</span>
{/if}
</p>
<p class="compose first line active" id="{$jid|cleanupId}-state" onclick="ChatActions_ajaxGetContact('{$contact->jid|echapJS}')"></p>
<p class="line active" onclick="ChatActions_ajaxGetContact('{$contact->jid|echapJS}')">

4
app/Widgets/ChatActions/ChatActions.php

@ -26,13 +26,13 @@ class ChatActions extends \Movim\Widget\Base
public function onBlock($packet)
{
Toast::send($this->__('blocked.account_blocked'));
$this->rpc('Chats_ajaxClose', $packet->content, true);
$this->rpc('Chat_ajaxGet', $packet->content);
}
public function onUnblock($packet)
{
Toast::send($this->__('blocked.account_unblocked'));
$this->rpc('Chats_ajaxClose', $packet->content, true);
$this->rpc('Chat_ajaxGet', $packet->content);
}
/**

8
app/Widgets/Chats/Chats.php

@ -413,17 +413,17 @@ class Chats extends Base
->whereNotIn('jidfrom', function ($query) {
$query->select('jid')
->from('open_chats')
->where('user_id', \App\User::me()->id);
->where('user_id', me()->id);
})
->whereNotIn('jidto', function ($query) {
$query->select('jid')
->from('open_chats')
->where('user_id', \App\User::me()->id);
->where('user_id', me()->id);
})
->groupBy('jidfrom', 'jidto')
->get()
->each(function ($message) use (&$toOpen) {
$jid = $message->jidfrom == \App\User::me()->id
$jid = $message->jidfrom == me()->id
? $message->jidto
: $message->jidfrom;
@ -438,7 +438,7 @@ class Chats extends Base
foreach ($toOpen as $jid => $published) {
$openChat = new OpenChat;
$openChat->user_id = \App\User::me()->id;
$openChat->user_id = me()->id;
$openChat->jid = $jid;
$openChat->created_at = $openChat->updated_at = $published;
$openChat->save(['timestamps' => false]);

16
app/Widgets/ContactActions/ContactActions.php

@ -11,6 +11,8 @@ use App\Widgets\Toast\Toast;
use Movim\CurrentCall;
use Movim\EmbedLight;
use Movim\Widget\Base;
use Moxl\Xec\Action\Blocking\Block;
use Moxl\Xec\Action\Blocking\Unblock;
class ContactActions extends Base
{
@ -147,6 +149,20 @@ class ContactActions extends Base
}
}
public function ajaxBlock(string $jid)
{
$block = new Block;
$block->setJid($jid);
$block->request();
}
public function ajaxUnblock(string $jid)
{
$block = new Unblock;
$block->setJid($jid);
$block->request();
}
public function ajaxHttpGetPictures($jid, $page = 0)
{
$tpl = $this->tpl();

42
app/Widgets/ContactActions/_contactactions_drawer.tpl

@ -42,6 +42,9 @@
<div>
<p class="line">
{$contact->truename}
{if="$contact->isBlocked()"}
<span class="tag color red">{$c->__('blocked.title')}</span>
{/if}
{if="$roster && $roster->group"}
<span class="tag color {$roster->group|stringToColor}">{$roster->group}</span>
{/if}
@ -197,13 +200,42 @@
<div class="tabelem spin" title="{$c->__('omemo.fingerprints_title')}" id="omemo_fingerprints"></div>
{/if}
<div id="adhoc_widget_{$jid|cleanupId}"
class="adhoc_widget tabelem"
<div id="adhoc_widget"
class="tabelem"
title="{$c->__('adhoc.title')}"
data-mobileicon="terminal" >
<div class="placeholder">
<i class="material-symbols">terminal</i>
<h1>{$c->__('adhoc.title')}</h1>
<ul class="list middle active divided">
{if="$contact->isBlocked()"}
<li onclick="ContactActions_ajaxUnblock('{$contact->id|echapJS}'); Drawer.clear();">
<span class="primary icon green">
<i class="material-symbols">cancel</i>
</span>
<span class="control icon gray">
<i class="material-symbols">chevron_right</i>
</span>
<div>
<p class="normal">{$c->__('blocked.unblock_account')}</p>
</div>
</li>
{else}
<li onclick="ContactActions_ajaxBlock('{$contact->id|echapJS}'); Drawer.clear();">
<span class="primary icon red">
<i class="material-symbols">block</i>
</span>
<span class="control icon gray">
<i class="material-symbols">chevron_right</i>
</span>
<div>
<p class="normal">{$c->__('blocked.block_account')}</p>
</div>
</li>
{/if}
</ul>
<div id="adhoc_widget_{$jid|cleanupId}">
<div class="placeholder">
<i class="material-symbols">terminal</i>
<h1>{$c->__('adhoc.title')}</h1>
</div>
</div>
</div>

3
app/Widgets/ContactHeader/_contactheader.tpl

@ -46,6 +46,9 @@
<div>
<p class="line active" onclick="ContactActions_ajaxGetDrawer('{$contact->id|echapJS}')">
{$contact->truename}
{if="$contact->isBlocked()"}
<span class="tag color red">{$c->__('blocked.title')}</span>
{/if}
{if="$roster && $roster->group"}
<span class="tag color {$roster->group|stringToColor}">{$roster->group}</span>
{/if}

1
app/Widgets/NewsNav/NewsNav.php

@ -23,6 +23,7 @@ class NewsNav extends Base
->orderBy('posts.published', 'desc')
->restrictToMicroblog()
->restrictUserHost()
->restrictReported()
->restrictNSFW()
->recents()
->take(6)

6
app/Widgets/Notif/Notif.php

@ -96,7 +96,7 @@ class Notif extends Base
// Push notification
if ($webPush) {
foreach (\App\User::me()->pushSubscriptions()->where('enabled', true)->whereNotNull('activity_at')->get() as $pushSubscription) {
foreach (me()->pushSubscriptions()->where('enabled', true)->whereNotNull('activity_at')->get() as $pushSubscription) {
$subscription = Subscription::create([
'endpoint' => $pushSubscription->endpoint,
'contentEncoding' => 'aesgcm',
@ -147,7 +147,7 @@ class Notif extends Base
}
if ($first === 'chat') {
RPC::call('Notif.counter', $first, (\App\User::me())->unreads(null, true));
RPC::call('Notif.counter', $first, (me())->unreads(null, true));
self::executeRPC();
} else {
RPC::call('Notif.counter', $first, $notifs[$first]);
@ -233,7 +233,7 @@ class Notif extends Base
if ($notifs == null) $notifs = [];
$notifs['chat'] = (\App\User::me())->unreads();
$notifs['chat'] = (me())->unreads();
RPC::call('Notif.refresh', $notifs);
}

2
app/Widgets/RoomsUtils/RoomsUtils.php

@ -844,7 +844,7 @@ class RoomsUtils extends Base
{
$g = new \Moxl\Xec\Action\MAM\Get;
$message = \App\User::me()->messages()
$message = me()->messages()
->where('jidfrom', $jid)
->whereNull('subject');

2
src/Movim/ChatStates.php

@ -106,6 +106,6 @@ class ChatStates
private function resolveJid(string $from, string $to)
{
return ($from == \App\User::me()->id) ? $to : $from;
return ($from == me()->id) ? $to : $from;
}
}

2
src/Movim/ChatroomPings.php

@ -36,7 +36,7 @@ class ChatroomPings
$this->clear($from);
$this->_chatrooms[$from] = $loop->addTimer($this->_pingIn, function () use ($from) {
$presence = \App\User::me()->session->conferences()
$presence = me()->session->conferences()
->where('conference', $from)
->first()?->presence;

2
src/Movim/Librairies/SDPtoJingle.php

@ -88,7 +88,7 @@ class SDPtoJingle
} else {
$this->jingle = new \SimpleXMLElement('<jingle></jingle>');
$this->jingle->addAttribute('xmlns', 'urn:xmpp:jingle:1');
$this->jingle->addAttribute('initiator', \App\User::me()->id);
$this->jingle->addAttribute('initiator', me()->id);
}
if ($action) {

2
src/Movim/Librairies/XMPPtoForm.php

@ -447,7 +447,7 @@ class XMPPtoForm
$select->setAttribute('id', $s['var']);
$select->setAttribute('name', $s['var']);
$subscriptions = \App\User::me()->subscriptions()
$subscriptions = me()->subscriptions()
->notComments()
->orderBy('server')->orderBy('node')
->get();

2
src/Movim/Widget/Base.php

@ -41,7 +41,7 @@ class Base
}
$this->setName();
$this->user = \App\User::me();
$this->user = me();
$this->load();
$this->baseUri = BASE_URI;

2
src/Moxl/API.php

@ -13,7 +13,7 @@ class API
$iq = $dom->createElementNS('jabber:client', 'iq');
$dom->appendChild($iq);
$me = \App\User::me();
$me = me();
if ($me->id && $me->session && $me->session->resource) {
$iq->setAttribute(

2
src/Moxl/Stanza/Presence.php

@ -28,7 +28,7 @@ class Presence
$root = $dom->createElementNS('jabber:client', 'presence');
$dom->appendChild($root);
$me = \App\User::me();
$me = me();
if ($me && $me->session) {
$root->setAttribute('from', $me->id . '/' . $me->session->resource);

2
src/Moxl/Xec/Action/Avatar/Set.php

@ -43,7 +43,7 @@ class Set extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($this->_to == false && $this->_node == false) {
$me = \App\User::me()->contact;
$me = me()->contact;
$me->avatartype = 'urn:xmpp:avatar:metadata';
$me->save();

2
src/Moxl/Xec/Action/BOB/Request.php

@ -20,7 +20,7 @@ class Request extends Action
$this->store();
// Only request if the resource is available
if (\App\User::me()->session?->presences()->where('jid', $this->_to)->where('resource', $this->_resource)->exists()
if (me()->session?->presences()->where('jid', $this->_to)->where('resource', $this->_resource)->exists()
&& $this->_algorythm) {
BOB::request($this->_to . '/' . $this->_resource, $this->_hash, $this->_algorythm);
}

4
src/Moxl/Xec/Action/Blocking/Block.php

@ -19,8 +19,8 @@ class Block extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$r = Reported::firstOrCreate(['id' => $this->_jid]);
\App\User::me()->reported()->syncWithoutDetaching([$r->id => ['synced' => true]]);
\App\User::me()->refreshBlocked();
me()->reported()->syncWithoutDetaching([$r->id => ['synced' => true]]);
me()->refreshBlocked();
$this->pack($this->_jid);
$this->deliver();

6
src/Moxl/Xec/Action/Blocking/Request.php

@ -31,13 +31,13 @@ class Request extends Action
];
})->toArray());
\App\User::me()->reported()->syncWithoutDetaching($jids->mapWithKeys(function ($jid) {
me()->reported()->syncWithoutDetaching($jids->mapWithKeys(function ($jid) {
return [$jid => ['synced' => true]];
}));
\App\User::me()->refreshBlocked();
me()->refreshBlocked();
// Retro-compatibility support
foreach (\App\User::me()->reported()->where('synced', false)->get() as $reported) {
foreach (me()->reported()->where('synced', false)->get() as $reported) {
$block = new Block;
$block->setJid($reported->id);
$block->request();

4
src/Moxl/Xec/Action/Blocking/Unblock.php

@ -17,8 +17,8 @@ class Unblock extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()->reported()->detach($this->_jid);
\App\User::me()->refreshBlocked();
me()->reported()->detach($this->_jid);
me()->refreshBlocked();
$this->pack($this->_jid);
$this->deliver();

2
src/Moxl/Xec/Action/Bookmark2/Delete.php

@ -18,7 +18,7 @@ class Delete extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()->session->conferences()->where('conference', $this->_id)->delete();
me()->session->conferences()->where('conference', $this->_id)->delete();
$this->deliver();
}
}

4
src/Moxl/Xec/Action/Bookmark2/Get.php

@ -19,7 +19,7 @@ class Get extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()
me()
->session
->conferences()
->where('bookmarkversion', (int)$this->_version)
@ -36,7 +36,7 @@ class Get extends Action
}
// We remove the conferences that might be saved under another bookmark version
\App\User::me()
me()
->session
->conferences()
->whereIn('conference', $conferenceIds)

2
src/Moxl/Xec/Action/Bookmark2/Set.php

@ -27,7 +27,7 @@ class Set extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()->session->conferences()
me()->session->conferences()
->where('conference', $this->_conference->conference)
->delete();

2
src/Moxl/Xec/Action/Jingle/SessionTerminate.php

@ -19,7 +19,7 @@ class SessionTerminate extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$userid = \App\User::me()->id;
$userid = me()->id;
$message = new \App\Message;
$message->user_id = $userid;
$message->id = 'm_' . generateUUID();

2
src/Moxl/Xec/Action/MAM/Get.php

@ -73,7 +73,7 @@ class Get extends Action
)
) {
$earliest = new MAMEarliest;
$earliest->user_id = \App\User::me()->id;
$earliest->user_id = me()->id;
$earliest->to = $this->_to;
$earliest->jid = $this->_jid;
$earliest->earliest = date(MOVIM_SQL_DATE, $this->_end ?? time());

8
src/Moxl/Xec/Action/OMEMO/DeleteBundle.php

@ -17,14 +17,14 @@ class DeleteBundle extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()->bundles()
->where('jid', \App\User::me()->id)
me()->bundles()
->where('jid', me()->id)
->where('bundleid', $this->_id)
->delete();
$devicesList = array_values(\App\User::me()->bundles()
$devicesList = array_values(me()->bundles()
->select('bundleid')
->where('jid', \App\User::me()->id)
->where('jid', me()->id)
->pluck('bundleid')
->toArray());

2
src/Moxl/Xec/Action/OMEMO/GetBundle.php

@ -30,7 +30,7 @@ class GetBundle extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($stanza->pubsub->items->item->bundle) {
$bundle = Bundle::where('user_id', \App\User::me()->id)
$bundle = Bundle::where('user_id', me()->id)
->where('jid', $this->_to)
->where('bundleid', $this->_id)
->first();

2
src/Moxl/Xec/Action/OMEMO/GetDeviceList.php

@ -24,7 +24,7 @@ class GetDeviceList extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()->bundles()->where('jid', $this->_to)->delete();
me()->bundles()->where('jid', $this->_to)->delete();
foreach ($stanza->pubsub->items->item as $item) {
if ((string)$item->attributes()->id == 'current' || $stanza->pubsub->items->count() == 1) {

4
src/Moxl/Xec/Action/Presence/Muc.php

@ -33,7 +33,7 @@ class Muc extends Action
}
if ($this->_mam == false && $this->_mam2 == false) {
\App\User::me()->messages()->where('jidfrom', $this->_to)->delete();
me()->messages()->where('jidfrom', $this->_to)->delete();
}
$this->store(); // Set stanzaId
@ -93,7 +93,7 @@ class Muc extends Action
}
if ($this->_mam) {
$message = \App\User::me()->messages()
$message = me()->messages()
->where('jidfrom', $this->_to)
->whereNull('subject');

2
src/Moxl/Xec/Action/PubsubSubscription/Remove.php

@ -26,7 +26,7 @@ class Remove extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($this->_pepnode == 'urn:xmpp:pubsub:movim-public-subscription') {
\App\User::me()->subscriptions()
me()->subscriptions()
->where('server', $this->_server)
->where('node', $this->_node)
->delete();

2
src/Moxl/Xec/Action/Roster/RemoveItem.php

@ -17,7 +17,7 @@ class RemoveItem extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
\App\User::me()
me()
->session
->contacts()
->where('jid', $this->_to)

2
src/Moxl/Xec/Action/Roster/UpdateItem.php

@ -20,7 +20,7 @@ class UpdateItem extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$roster = \App\User::me()->session->contacts()->where('jid', $this->_to)->first();
$roster = me()->session->contacts()->where('jid', $this->_to)->first();
if ($roster) {
$roster->name = $this->_name;

2
src/Moxl/Xec/Action/Session/Bind.php

@ -17,7 +17,7 @@ class Bind extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$session = \App\User::me()->session;
$session = me()->session;
$jid = explodeJid((string)$stanza->bind->jid);

2
src/Moxl/Xec/Action/Session/Start.php

@ -21,7 +21,7 @@ class Start extends Action
$session = Session::instance();
$session->delete('password');
$session = \App\User::me()->session;
$session = me()->session;
$session->active = true;
$session->save();

2
src/Moxl/Xec/Action/Vcard4/Set.php

@ -19,7 +19,7 @@ class Set extends Action
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$this->pack(\App\User::me()->contact);
$this->pack(me()->contact);
$this->deliver();
}

4
src/Moxl/Xec/Payload/Blocked.php

@ -11,8 +11,8 @@ class Blocked extends Payload
$jid = (string)$stanza->item->attributes()->jid;
$r = Reported::firstOrCreate(['id' => $jid]);
\App\User::me()->reported()->syncWithoutDetaching([$r->id => ['synced' => true]]);
\App\User::me()->refreshBlocked();
me()->reported()->syncWithoutDetaching([$r->id => ['synced' => true]]);
me()->refreshBlocked();
$this->pack($jid);
$this->deliver();

6
src/Moxl/Xec/Payload/Bookmark2.php

@ -8,11 +8,11 @@ class Bookmark2 extends Payload
{
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if (baseJid((string)$parent->attributes()->from) != \App\User::me()->id
if (baseJid((string)$parent->attributes()->from) != me()->id
|| (string)$parent->attributes()->from == (string)$parent->attributes()->to) return;
if ($stanza->items->retract) {
\App\User::me()->session
me()->session
->conferences()
->where('conference', (string)$stanza->items->retract->attributes()->id)
->delete();
@ -20,7 +20,7 @@ class Bookmark2 extends Payload
$conference = new Conference;
$conference->set($stanza->items->item);
\App\User::me()->session->conferences()->where('conference', $conference->conference)->delete();
me()->session->conferences()->where('conference', $conference->conference)->delete();
$conference->save();

2
src/Moxl/Xec/Payload/CallInviteAccept.php

@ -9,7 +9,7 @@ class CallInviteAccept extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($parent->{'stanza-id'} && $parent->{'stanza-id'}->attributes()->xmlns == 'urn:xmpp:sid:0') {
$muji = \App\User::me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
$muji = me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
if ($muji) {
MujiCallParticipant::firstOrCreate([

2
src/Moxl/Xec/Payload/CallInviteLeft.php

@ -10,7 +10,7 @@ class CallInviteLeft extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($parent->{'stanza-id'} && $parent->{'stanza-id'}->attributes()->xmlns == 'urn:xmpp:sid:0') {
$muji = \App\User::me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
$muji = me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
if ($muji) {
MujiCallParticipant::firstOrCreate([

2
src/Moxl/Xec/Payload/CallInvitePropose.php

@ -16,7 +16,7 @@ class CallInvitePropose extends Payload
CurrentCall::getInstance()->isStarted()
&& CurrentCall::getInstance()->isJidInCall(baseJid($parent->attributes()->from))
) {
$conference = \App\User::me()->session->conferences()->where('conference', \baseJid((string)$parent->attributes()->from))->first();
$conference = me()->session->conferences()->where('conference', \baseJid((string)$parent->attributes()->from))->first();
if ($conference) {
// If the propose is from another person

2
src/Moxl/Xec/Payload/CallInviteRetract.php

@ -11,7 +11,7 @@ class CallInviteRetract extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($parent->{'stanza-id'} && $parent->{'stanza-id'}->attributes()->xmlns == 'urn:xmpp:sid:0') {
$muji = \App\User::me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
$muji = me()->session->mujiCalls()->where('id', (string)$stanza->attributes()->id)->first();
if ($muji) {
$participant = $muji->participants->firstWhere('jid', $parent->attributes()->from);

4
src/Moxl/Xec/Payload/Carbons.php

@ -9,7 +9,7 @@ class Carbons extends Payload
$parentfrom = baseJid((string)$parent->attributes()->from);
$message = $stanza->forwarded->message;
if ($parentfrom == \App\User::me()->id) {
if ($parentfrom == me()->id) {
if ($message->retract
&& $message->retract->attributes()->xmlns == 'urn:xmpp:message-retract:1') {
$retracted = new Retracted;
@ -42,7 +42,7 @@ class Carbons extends Payload
} elseif (count($jingle_messages = $stanza->xpath('//*[@xmlns="urn:xmpp:jingle-message:0"]')) >= 1) {
$callto = baseJid((string)$message->attributes()->to);
if ($callto == \App\User::me()->id || $callto == "") {
if ($callto == me()->id || $callto == "") {
// We get carbons for calls other clients make as well as calls other clients receive
// So make sure we only ring when we see a call _to_ us
// Or with no "to", which means from ourselves to ourselves, like another client's <accept>

6
src/Moxl/Xec/Payload/Displayed.php

@ -8,13 +8,13 @@ class Displayed extends Payload
{
// Handle only MUC messages with a proper stanza-id
$message = ('groupchat' == (string)$parent->attributes()->type)
? \App\User::me()->messages()
? me()->messages()
->where('stanzaid', (string)$stanza->attributes()->id)
->where('jidfrom', current(explode('/',
(string)$parent->attributes()->from
)))
->first()
: \App\User::me()->messages()
: me()->messages()
->where('originid', (string)$stanza->attributes()->id)
->where('jidfrom', current(explode('/',
(string)$parent->attributes()->to
@ -26,7 +26,7 @@ class Displayed extends Payload
$message->save();
if ($message->jidto == $message->user_id) {
\App\User::me()->messages()
me()->messages()
->where('jidfrom', $message->jidfrom)
->where('seen', false)
->update(['seen' => true]);

2
src/Moxl/Xec/Payload/Location.php

@ -15,7 +15,7 @@ class Location extends Payload
$contact->setLocation($stanza->items->item);
$contact->save();
if ($from == \App\User::me()->id) {
if ($from == me()->id) {
$this->event('mylocation');
$this->event('mypresence');
} else {

2
src/Moxl/Xec/Payload/Message.php

@ -37,7 +37,7 @@ class Message extends Payload
return;
}
if ($message->type == 'chat' && \App\User::me()->hasBlocked($message->jidfrom)) {
if ($message->type == 'chat' && me()->hasBlocked($message->jidfrom)) {
return;
}

2
src/Moxl/Xec/Payload/Moderated.php

@ -7,7 +7,7 @@ class Moderated extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if ($parent->{'apply-to'} && $parent->{'apply-to'}->attributes()->xmlns == 'urn:xmpp:fasten:0') {
$message = \App\User::me()->messages()
$message = me()->messages()
->where('stanzaid', (string)$parent->{'apply-to'}->attributes()->id)
->where('jidfrom', baseJid((string)$parent->attributes()->from))
->first();

2
src/Moxl/Xec/Payload/OMEMODevices.php

@ -22,7 +22,7 @@ class OMEMODevices extends Payload
}
// Remove all the cached devices not in the list
Bundle::where('user_id', \App\User::me()->id)
Bundle::where('user_id', me()->id)
->where('jid', $from)
->whereNotIn('bundleid', $devicesIds)
->delete();

6
src/Moxl/Xec/Payload/Presence.php

@ -16,7 +16,7 @@ class Presence extends Payload
{
$jid = explodeJid($stanza->attributes()->from);
if (\App\User::me()->hasBlocked($jid['jid'])) {
if (me()->hasBlocked($jid['jid'])) {
return;
}
@ -30,7 +30,7 @@ class Presence extends Payload
$presence->set($stanza);
if (CurrentCall::getInstance()->isStarted() && CurrentCall::getInstance()->mujiRoom == $jid['jid']) {
$muji = \App\User::me()->session->mujiCalls()
$muji = me()->session->mujiCalls()
->where('muc', $jid['jid'])
->first();
@ -53,7 +53,7 @@ class Presence extends Payload
if ($presence->muc) {
ChatroomPings::getInstance()->touch($presence->jid);
if ($presence->mucjid == \App\User::me()->id) {
if ($presence->mucjid == me()->id) {
// Spectrum2 specific bug, we can receive two self-presences, one with several caps items
$cCount = 0;
foreach ($stanza->children() as $key => $content) {

4
src/Moxl/Xec/Payload/ReceiptAck.php

@ -8,13 +8,13 @@ class ReceiptAck extends Payload
{
// Handle only MUC messages with a proper stanza-id
$message = ('groupchat' == (string)$parent->attributes()->type)
? \App\User::me()->messages()
? me()->messages()
->where('stanzaid', (string)$stanza->attributes()->id)
->where('jidfrom', current(explode('/',
(string)$parent->attributes()->from
)))
->first()
: \App\User::me()->messages()
: me()->messages()
->where('originid', (string)$stanza->attributes()->id)
->where('jidfrom', current(explode('/',
(string)$parent->attributes()->to

2
src/Moxl/Xec/Payload/ReceiptRequest.php

@ -15,7 +15,7 @@ class ReceiptRequest extends Payload
\Moxl\Stanza\Message::received(baseJid($from), $id, (string)$parent->attributes()->type);
$message = \App\User::me()->messages()
$message = me()->messages()
->where('originid', $id)
->where('jidfrom', baseJid($from))
->first();

2
src/Moxl/Xec/Payload/Retracted.php

@ -15,7 +15,7 @@ class Retracted extends Payload
) ? 'stanzaid'
: 'originid';
$message = \App\User::me()->messages()
$message = me()->messages()
->where($idKey, (string)$stanza->attributes()->id)
->where('jidfrom', baseJid((string)$parent->attributes()->from))
->first();

2
src/Moxl/Xec/Payload/Roster.php

@ -10,7 +10,7 @@ class Roster extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
if (!$parent->attributes()->from
|| (baseJid((string)$parent->attributes()->from) != \App\User::me()->id)
|| (baseJid((string)$parent->attributes()->from) != me()->id)
) return;
if ((string)$parent->attributes()->type == 'set') {

2
src/Moxl/Xec/Payload/SASL2Success.php

@ -11,7 +11,7 @@ class SASL2Success extends Payload
$memorySession = Session::instance();
$memorySession->delete('password');
$session = \App\User::me()->session;
$session = me()->session;
$jid = explodeJid((string)$stanza->{'authorization-identifier'});

2
src/Moxl/Xec/Payload/SASLSuccess.php

@ -8,6 +8,6 @@ class SASLSuccess extends Payload
{
$this->deliver();
\Moxl\Stanza\Stream::init(\App\User::me()->session->host, \App\User::me()->id);
\Moxl\Stanza\Stream::init(me()->session->host, me()->id);
}
}

2
src/Moxl/Xec/Payload/SessionBind.php

@ -9,7 +9,7 @@ class SessionBind extends Payload
public function handle(?\SimpleXMLElement $stanza = null, ?\SimpleXMLElement $parent = null)
{
$ss = new Bind;
$ss->setResource(\App\User::me()->session->resource)
$ss->setResource(me()->session->resource)
->request();
}
}

4
src/Moxl/Xec/Payload/Unblocked.php

@ -8,8 +8,8 @@ class Unblocked extends Payload
{
$jid = (string)$stanza->item->attributes()->jid;
\App\User::me()->reported()->detach($jid);
\App\User::me()->refreshBlocked();
me()->reported()->detach($jid);
me()->refreshBlocked();
$this->pack($jid);
$this->deliver();

Loading…
Cancel
Save