Browse Source

Fix #1253 Use User Nickname for MUC nickname when no nick present in bookmark

Add a small hint in the Vcard form to explain that the nickname will be used like this
pull/1256/head
Timothée Jaussoin 2 years ago
parent
commit
f6bbf8ef6b
  1. 7
      app/User.php
  2. 4
      app/widgets/Chat/Chat.php
  3. 1
      app/widgets/Publish/publish.css
  4. 2
      app/widgets/Rooms/Rooms.php
  5. 8
      app/widgets/RoomsUtils/RoomsUtils.php
  6. 1
      app/widgets/Vcard4/_vcard4_form.tpl
  7. 1
      app/widgets/Vcard4/locales.ini
  8. 4
      public/theme/css/form.css

7
app/User.php

@ -78,6 +78,13 @@ class User extends Model
return $this->belongsToMany(User::class, 'post_user_views', 'user_id', 'post_id')->withTimestamps();
}
public function getUsernameAttribute()
{
return $this->contact && $this->contact->nickname
? $this->contact->nickname
: $this->session->username;
}
public function getResolvedNicknameAttribute()
{
return $this->nickname ?? $this->id;

4
app/widgets/Chat/Chat.php

@ -579,7 +579,7 @@ class Chat extends \Movim\Widget\Base
if ($muc) {
$m->type = 'groupchat';
$m->resource = $this->user->session->username;
$m->resource = $this->user->username;
$m->jidfrom = $to;
}
@ -732,7 +732,7 @@ class Chat extends \Movim\Widget\Base
$reaction = new Reaction;
$reaction->message_mid = $parentMessage->mid;
$reaction->jidfrom = ($parentMessage->isMuc())
? $this->user->session->username
? $this->user->username
: $this->user->id;
$reaction->created_at = $now;
$reaction->updated_at = $now;

1
app/widgets/Publish/publish.css

@ -24,7 +24,6 @@
#publish textarea[name=content] {
min-height: 25rem;
margin-bottom: 0;
}
#publish span.privacy form > div .checkbox > input[type="checkbox"] + label {

2
app/widgets/Rooms/Rooms.php

@ -205,7 +205,7 @@ class Rooms extends Base
$p->setTo($room);
if ($nickname == false) {
$nickname = $this->user->session->username;
$nickname = $this->user->username;
}
$jid = explodeJid($room);

8
app/widgets/RoomsUtils/RoomsUtils.php

@ -314,7 +314,7 @@ class RoomsUtils extends Base
->request();
// Disconnect properly
$nick = $values['nick'] ?? $this->user->session->username;
$nick = $values['nick'] ?? $this->user->username;
$session = Session::start();
$session->delete($values['jid'] . '/' . $nick);
@ -402,7 +402,7 @@ class RoomsUtils extends Base
->where('conference', $room)->first()
);
$view->assign('name', $name);
$view->assign('username', $this->user->session->username);
$view->assign('username', $this->user->username);
$gateways = \App\Info::select('name', 'server', 'parent')
->whereCategory('gateway')
@ -452,7 +452,7 @@ class RoomsUtils extends Base
$m = new Muc;
$m->enableCreate()
->setTo(strtolower($form->jid->value))
->setNickname($form->nick->value ?? $this->user->session->username)
->setNickname($form->nick->value ?? $this->user->username)
->request();
}
}
@ -468,7 +468,7 @@ class RoomsUtils extends Base
->setName($form->name->value)
->setAutoJoin($form->autojoin->value)
->setPinned($form->pinned->value)
->setNick($form->nick->value ?? $this->user->session->username)
->setNick($form->nick->value ?? $this->user->username)
->setNotify((int)array_flip(Conference::$notifications)[$form->notify->value])
->request();
} elseif ($form->type->value == 'channel') {

1
app/widgets/Vcard4/_vcard4_form.tpl

@ -16,6 +16,7 @@
<div>
<input dir="auto" type="text" name="name" value="{$contact->name ?? ''}" placeholder="{$c->__('general.nickname')}">
<label for="name">{$c->__('general.nickname')}</label>
<span class="supporting"><i class="material-icons">lightbulb</i> {$c->__('vcard.nickname_info')}</span>
</div>
</li>
<li>

1
app/widgets/Vcard4/locales.ini

@ -2,6 +2,7 @@
title = Profile
updated = Profile Updated
not_updated = Profile Not Updated
nickname_info = This will also be used as your default nickname when joining a chatroom
[profile]
public = Your profile is now public

4
public/theme/css/form.css

@ -158,12 +158,12 @@ form > div.compact > textarea {
}
/* Supporting text */
form > div > span.supporting {
form div > span.supporting {
line-height: 2.25rem;
font-size: 1.5rem;
color: rgba(var(--movim-font), 0.60);
display: inline-block;
margin: 1rem 0;
margin-bottom: 1rem;
}
/* Webkit hack */

Loading…
Cancel
Save