Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
(feat): enforce message permission flag
· b4e83ad9
Marcelo Rivera
authored
Oct 10, 2019
b4e83ad9
(feat): enforce JOIN permission flag on groups
· 2627ae77
Marcelo Rivera
authored
Oct 10, 2019
2627ae77
Hide whitespace changes
Inline
Side-by-side
src/app/modules/groups/groups-join-button.ts
View file @
2627ae77
...
...
@@ -4,6 +4,9 @@ import { Router } from '@angular/router';
import
{
GroupsService
}
from
'
./groups-service
'
;
import
{
Session
}
from
'
../../services/session
'
;
import
{
LoginReferrerService
}
from
'
../../services/login-referrer.service
'
;
import
{
PermissionsService
}
from
'
../../common/services/permissions/permissions.service
'
;
import
{
FeaturesService
}
from
'
../../services/features.service
'
;
import
{
Flags
}
from
'
../../common/services/permissions/flags
'
;
@
Component
({
selector
:
'
minds-groups-join-button
'
,
...
...
@@ -79,7 +82,9 @@ export class GroupsJoinButton {
public
session
:
Session
,
public
service
:
GroupsService
,
private
router
:
Router
,
private
loginReferrer
:
LoginReferrerService
private
loginReferrer
:
LoginReferrerService
,
private
featuresService
:
FeaturesService
,
private
permissionsService
:
PermissionsService
)
{
this
.
minds
=
window
.
Minds
;
}
...
...
@@ -116,6 +121,14 @@ export class GroupsJoinButton {
this
.
router
.
navigate
([
'
/login
'
]);
return
;
}
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
group
,
Flags
.
JOIN
)
)
{
return
;
}
this
.
inProgress
=
true
;
this
.
service
.
join
(
this
.
group
)
...
...
src/app/modules/messenger/conversation/conversation.component.ts
View file @
2627ae77
...
...
@@ -6,6 +6,8 @@ import {
Renderer
,
ViewChild
,
Injector
,
OnInit
,
OnDestroy
,
}
from
'
@angular/core
'
;
import
{
Client
}
from
'
../../../services/api
'
;
...
...
@@ -18,6 +20,9 @@ import { MessengerEncryptionService } from '../encryption/encryption.service';
import
{
MessengerConversationDockpanesService
}
from
'
../dockpanes/dockpanes.service
'
;
import
{
MessengerSounds
}
from
'
../sounds/service
'
;
import
{
BlockListService
}
from
'
../../../common/services/block-list.service
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
@
Component
({
moduleId
:
module
.
id
,
...
...
@@ -29,7 +34,7 @@ import { BlockListService } from '../../../common/services/block-list.service';
inputs
:
[
'
conversation
'
],
templateUrl
:
'
conversation.component.html
'
,
})
export
class
MessengerConversation
{
export
class
MessengerConversation
implements
OnInit
,
OnDestroy
{
minds
:
Minds
=
window
.
Minds
;
sounds
=
new
MessengerSounds
();
...
...
@@ -81,7 +86,9 @@ export class MessengerConversation {
private
renderer
:
Renderer
,
public
encryption
:
MessengerEncryptionService
,
public
dockpanes
:
MessengerConversationDockpanesService
,
protected
blockListService
:
BlockListService
protected
blockListService
:
BlockListService
,
protected
featuresService
:
FeaturesService
,
protected
permissionsService
:
PermissionsService
)
{
this
.
buildTabId
();
}
...
...
@@ -130,8 +137,8 @@ export class MessengerConversation {
this
.
messages
=
this
.
messages
.
concat
(
response
.
messages
);
this
.
scrollEmitter
.
next
(
true
);
}
else
if
(
opts
.
offset
)
{
le
t
scrollTop
=
scrollView
.
scrollTop
;
le
t
scrollHeight
=
scrollView
.
scrollHeight
;
cons
t
scrollTop
=
scrollView
.
scrollTop
;
cons
t
scrollHeight
=
scrollView
.
scrollHeight
;
if
(
this
.
messages
.
length
)
{
response
.
messages
.
pop
();
}
...
...
@@ -249,6 +256,13 @@ export class MessengerConversation {
send
(
e
)
{
e
.
preventDefault
();
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
conversation
,
Flags
.
MESSAGE
)
)
{
return
;
}
if
(
this
.
blocked
||
!
this
.
message
||
...
...
@@ -258,7 +272,7 @@ export class MessengerConversation {
return
;
}
le
t
newLength
=
this
.
messages
.
push
({
cons
t
newLength
=
this
.
messages
.
push
({
// Optimistic
optimisticGuess
:
true
,
owner
:
this
.
session
.
getLoggedInUser
(),
...
...
@@ -332,7 +346,7 @@ export class MessengerConversation {
this
.
blockingActionInProgress
=
true
;
le
t
blocks
=
[],
cons
t
blocks
=
[],
newState
=
!
this
.
blocked
;
this
.
conversation
.
participants
.
forEach
((
participant
:
any
)
=>
{
...
...