Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid "Invalid user error" #192

Closed
haosdent opened this issue Jun 17, 2015 · 13 comments
Closed

How to avoid "Invalid user error" #192

haosdent opened this issue Jun 17, 2015 · 13 comments
Assignees
Milestone

Comments

@haosdent
Copy link
Contributor

Hello, I try to write a third part plugin like packages/rocketchat-hubot. But I meet this error when I call Meteor.call "sendMessage".

Exception in callback of async function: Error: [methods] sendMessage -> Invalid user [invalid-user]

I check the code of rocketchat-hubot, but seem it also don't set userid. I am confuse here, how could I avoid this error. Thank you in advance.

@haosdent
Copy link
Contributor Author

My code snippet is

        Meteor.call "sendMessage",
            u:
                username: name
            to: target
            msg: content
            rid: 'EtomNKRwxp6mELsGGLHa4ybHScj2WZoo3K'

I have already wrap this function by Meteor.bindEnvironment before.

@sampaiodiego
Copy link
Member

maybe @Sing-Li can answer this?

@engelgabriel
Copy link
Member

@haosdent did you create a user for Hubot? You need to register yourself as Hubot, and set the login credentials on the hubot server via environment variables.

@engelgabriel
Copy link
Member

We need to add a default Hubot user and generate a random token, visible to the admin

@haosdent
Copy link
Contributor Author

Thank you for your reply. @Sing-Li @engelgabriel .
In fact, I try to write a irc plugin for rocket.chat. https://github.com/haosdent/rocketchat-irc/blob/master/irc.server.coffee

And it could works although it only have the basic communicate function.

Channel message:
haosdentd___hadoop__153__n__hadoop-_http___hadoop_ap
rocket_chat

Direct message:
haosdentd
rocket_chat

@haosdent
Copy link
Contributor Author

I add a receiveMessage to Meteor.methods in server directory. But I am not sure whether it is the best way or not.

@engelgabriel
Copy link
Member

That looks cool! Lets me try it and I'll give you some feedback. About the receiveMessage, I had a similar idea... let's talk about it after I have had read the code.

@haosdent
Copy link
Contributor Author

Thank you for your great help.

@engelgabriel
Copy link
Member

@haosdent do you want make a pull request with yous script? I'd be glad to accept it. We just need to turn all the configuration loaded form the DB... so we can setup using an admin interface.

@haosdent
Copy link
Contributor Author

Sure and very gladful you want to accept it. Let me fix some minor issue of my scripts and create a merge request.

@Sing-Li
Copy link
Member

Sing-Li commented Jun 19, 2015

Cool! Now we can 'bridge in' mainstream OSS project IRC channels 👍

@engelgabriel engelgabriel self-assigned this Jun 30, 2015
@engelgabriel
Copy link
Member

@haosdent

I've split the /server/methods/sendMessage.coffee method into the server method that can be called by the client (that has to pass all auth/permissions check) and the rest main functionality is now on a function in /packages/rocketchat-lib/server/sendMessage.coffee that can only be called by server side scripts (without auth/permissions checks)

This should eliminate the need of your /server/methods/receiveMessage.coffee

Can you please review it? And send a PR migrating to the new method?

@haosdent
Copy link
Contributor Author

haosdent commented Jul 1, 2015

Thank you very much! I see it, let me migrate.

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

No branches or pull requests

5 participants