-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
In the following snippet you can see that it is assumed that ev.resource.from.username is defined, but then, the existence of ev.resource is checked. So if ev.resource is definitely there, why check for it? Should the conditional be changed, then, to not assume ev.resource.from.username is a true object path in every event?
For context, I am looking at this because I'm actually interested in self-sent messages. I'm puzzled as to why there is a comment here saying there would be an infinite-loop. I'm using the generic event event in order to pick up self-sent messages now as a result, although I'd have preferred the Text/RichText ones.
Lines 93 to 101 in 08666d1
| // Prevent infinite-loop (echo itself) | |
| if (ev.resource.from.username === this.context.username) { | |
| return; | |
| } | |
| if (ev && ev.resource && ev.resource.type === "Text") { | |
| this.emit("Text", ev.resource); | |
| } else if (ev && ev.resource && ev.resource.type === "RichText") { | |
| this.emit("RichText", ev.resource); |
// Prevent infinite-loop (echo itself)
if (ev.resource.from.username === this.context.username) {
return;
}
if (ev && ev.resource && ev.resource.type === "Text") {
this.emit("Text", ev.resource);
} else if (ev && ev.resource && ev.resource.type === "RichText") {
this.emit("RichText", ev.resource);
demurgos
Metadata
Metadata
Assignees
Labels
No labels