Skip to content

host.go: Fixing bug with /reply#230

Merged
shazow merged 1 commit intoshazow:masterfrom
ste5e99:replyfix
Apr 28, 2017
Merged

host.go: Fixing bug with /reply#230
shazow merged 1 commit intoshazow:masterfrom
ste5e99:replyfix

Conversation

@ste5e99
Copy link
Copy Markdown
Contributor

@ste5e99 ste5e99 commented Apr 27, 2017

Wrapping the reply action within a Host.GetUser() check to safely assure that the user being replied to is still online. This should resolve #228.

Screenshot included demo'ing the fix:
sample

host.go Outdated
completed = "/msg " + replyTo.Name()
name := replyTo.Name()
_, found := h.GetUser(name)
if !found {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that the opposite condition we want?

_, found := h.GetUser(name)
if !found {
completed = "/msg " + name
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not found, could you also reset the state of u.ReplyTo? I think u.SetReplyTo(nil) should do the trick.

@ste5e99
Copy link
Copy Markdown
Contributor Author

ste5e99 commented Apr 27, 2017

I fixed my logic mistake and added an else branch to do u.SetReplyTo(nil).

@shazow
Copy link
Copy Markdown
Owner

shazow commented Apr 28, 2017

Awesome looks good. Now why is travis upset...

@ste5e99
Copy link
Copy Markdown
Contributor Author

ste5e99 commented Apr 28, 2017 via email

@shazow shazow merged commit e800c88 into shazow:master Apr 28, 2017
@shazow
Copy link
Copy Markdown
Owner

shazow commented Apr 28, 2017

Tried it locally, works, yolo.

name := target.Name()
_, found := h.GetUser(name)
if !found {
return errors.New("user not found")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I couldn't make it reach this branch locally, weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/reply does not fail properly when user target is missing

2 participants