Message does not provide a setFrom() method
Closed this issue · 9 comments
Currently, the GorkaLaucirica\HipchatAPIv2Client\Model\Message
class does not provide a getFrom()
or setFrom()
method, so it is not possible to set the message author.
Running into this now. These methods should be added.
I've added a setFrom() method on the Message model, and even when data is provided it is ignored.
setFrom()
IMHO does not make any sense as API does not allow to impersonate other users as you can see in the following two methods:
https://www.hipchat.com/docs/apiv2/method/private_message_user
https://www.hipchat.com/docs/apiv2/method/send_room_notification
What's exactly your use case?
My particular use case is as follows. I'm developing a subscription management system. When a subscription is granted to a client by an administrator, I'd like to be able to post as the administrator in the HipChat room so that the other members of the (private) room can see which sales person has performed the action and on which account. There are a number of different instances where it would be very useful to be able to specify who the message comes from.
Sorry for the delay, for your use case I would create an new user and use its token to post the notifications
I think my explanation was poorly worded. In my back-end system, a user (Joe) performs an actions. When doing so, I'd like the HipChat message generated to look like it has been sent from that user (Joe). As there are several existing users of my system, who are already registered within HipChat it's not feasible for all messages to come from a single bot
user.
Push this. I agree with @drawmyattention. Having a similar use case here, where I need a bot to post news. It's the easiest way to provide my user token and post to the room using this token, but it should be clear to everyone that it was a bot who posted the new message. That's why I want to change the "from" value to the bot's name.
Also, the api documentation does not discourage to change the "from" value, so it should be possible to do so.
I created PR #25 which just adds getter/setter for 'from'. So whoever wants to use it could do so, the others won't need to. :-)
I retire my explanation. Just found out, that it's super easy to create a token for a room and pass a label to the token. So there is no need to set it with each method.
Nevertheless, I think that the "from" value should be editable in case you want to pass an additional label with a message. As stated in the docs... ;-)
Added in #29