Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
28d48bf8
Unverified
Commit
28d48bf8
authored
6 years ago
by
Bradley Hilton
Browse files
Options
Downloads
Patches
Plain Diff
Fix the reaction endpoint only working with regular emojis
parent
9637a709
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/rocketchat-reactions/setReaction.js
+14
-13
14 additions, 13 deletions
packages/rocketchat-reactions/setReaction.js
with
14 additions
and
13 deletions
packages/rocketchat-reactions/setReaction.js
+
14
−
13
View file @
28d48bf8
...
...
@@ -2,7 +2,7 @@
import
_
from
'
underscore
'
;
Meteor
.
methods
({
setReaction
(
reaction
,
messageId
)
{
setReaction
(
emoji
,
messageId
)
{
if
(
!
Meteor
.
userId
())
{
throw
new
Meteor
.
Error
(
'
error-invalid-user
'
,
'
Invalid user
'
,
{
method
:
'
setReaction
'
});
}
...
...
@@ -19,9 +19,10 @@ Meteor.methods({
throw
new
Meteor
.
Error
(
'
error-not-allowed
'
,
'
Not allowed
'
,
{
method
:
'
setReaction
'
});
}
reaction
=
`:
${
reaction
.
replace
(
/:/g
,
''
)
}
:`
;
const
reactionWithoutColon
=
emoji
.
replace
(
/:/g
,
''
);
const
reactionWithColon
=
`:
${
reactionWithoutColon
}
:`
;
if
(
!
RocketChat
.
emoji
.
list
[
reaction
]
&&
RocketChat
.
models
.
EmojiCustom
.
findByNameOrAlias
(
reaction
).
count
()
===
0
)
{
if
(
!
RocketChat
.
emoji
.
list
[
reaction
WithColon
]
&&
RocketChat
.
models
.
EmojiCustom
.
findByNameOrAlias
(
reaction
WithoutColon
).
count
()
===
0
)
{
throw
new
Meteor
.
Error
(
'
error-not-allowed
'
,
'
Invalid emoji provided.
'
,
{
method
:
'
setReaction
'
});
}
...
...
@@ -39,34 +40,34 @@ Meteor.methods({
return
false
;
}
if
(
message
.
reactions
&&
message
.
reactions
[
reaction
]
&&
message
.
reactions
[
reaction
].
usernames
.
indexOf
(
user
.
username
)
!==
-
1
)
{
message
.
reactions
[
reaction
].
usernames
.
splice
(
message
.
reactions
[
reaction
].
usernames
.
indexOf
(
user
.
username
),
1
);
if
(
message
.
reactions
&&
message
.
reactions
[
reaction
WithColon
]
&&
message
.
reactions
[
reaction
WithColon
].
usernames
.
indexOf
(
user
.
username
)
!==
-
1
)
{
message
.
reactions
[
reaction
WithColon
].
usernames
.
splice
(
message
.
reactions
[
reaction
WithColon
].
usernames
.
indexOf
(
user
.
username
),
1
);
if
(
message
.
reactions
[
reaction
].
usernames
.
length
===
0
)
{
delete
message
.
reactions
[
reaction
];
if
(
message
.
reactions
[
reaction
WithColon
].
usernames
.
length
===
0
)
{
delete
message
.
reactions
[
reaction
WithColon
];
}
if
(
_
.
isEmpty
(
message
.
reactions
))
{
delete
message
.
reactions
;
RocketChat
.
models
.
Messages
.
unsetReactions
(
messageId
);
RocketChat
.
callbacks
.
run
(
'
unsetReaction
'
,
messageId
,
reaction
);
RocketChat
.
callbacks
.
run
(
'
unsetReaction
'
,
messageId
,
reaction
WithColon
);
}
else
{
RocketChat
.
models
.
Messages
.
setReactions
(
messageId
,
message
.
reactions
);
RocketChat
.
callbacks
.
run
(
'
setReaction
'
,
messageId
,
reaction
);
RocketChat
.
callbacks
.
run
(
'
setReaction
'
,
messageId
,
reaction
WithColon
);
}
}
else
{
if
(
!
message
.
reactions
)
{
message
.
reactions
=
{};
}
if
(
!
message
.
reactions
[
reaction
])
{
message
.
reactions
[
reaction
]
=
{
if
(
!
message
.
reactions
[
reaction
WithColon
])
{
message
.
reactions
[
reaction
WithColon
]
=
{
usernames
:
[]
};
}
message
.
reactions
[
reaction
].
usernames
.
push
(
user
.
username
);
message
.
reactions
[
reaction
WithColon
].
usernames
.
push
(
user
.
username
);
RocketChat
.
models
.
Messages
.
setReactions
(
messageId
,
message
.
reactions
);
RocketChat
.
callbacks
.
run
(
'
setReaction
'
,
messageId
,
reaction
);
RocketChat
.
callbacks
.
run
(
'
setReaction
'
,
messageId
,
reaction
WithColon
);
}
msgStream
.
emit
(
message
.
rid
,
message
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment