Skip to Content Skip to Menu

Bug in uddeIm API when you want to send message to user

6 years 1 month ago - 6 years 1 month ago #307473 by Quark Zimmerman
Basically the bug is in function:
function sendNewSysMessage($fromid, $recipients, $message, $systemmsg=0, $validfor=0, $sendnotification=0, $forceembedded=0)
( uddeim.api.php )

around line 316 (in v4) , that if you wish to send message to specific user (recipient) does following query:

$sql="SELECT DISTINCT u.id FROM (#__users AS u INNER JOIN `#__user_usergroup_map` AS um ON u.id=um.user_id)
INNER JOIN `#__usergroups` AS g ON um.group_id=g.id
WHERE u.block=0 AND g.id=".(int)$recipients;

as result the list returns empty as it check user group id, not specific user id. So message is not sent to no one.

The fix is to change the query a bit:

$sql="SELECT DISTINCT u.id FROM (#__users AS u INNER JOIN `#__user_usergroup_map` AS um ON u.id=um.user_id)
INNER JOIN `#__usergroups` AS g ON um.group_id=g.id
WHERE u.block=0 AND u.id=".(int)$recipients;

Just replace g (group table) with u (user table) and it will find user and send to him.
Last edit: 6 years 1 month ago by Quark Zimmerman.

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
6 years 1 month ago #307474 by slabbi
System messages should be sent to groups, so "recipients" shoud be a group id.

This is documented in uddeIM FAQ:
(int) recipients = [all: all users | online: all logged in users | special: all special users | admins: all admins | <groupid>: all members of group <groupid> ]

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

6 years 1 month ago #307475 by Quark Zimmerman
Replied by Quark Zimmerman on topic Bug in uddeIm API when you want to send message to user
Thanks, but what if I need to send to specific user? What function I should use?

Basically I have an event in my system (it's a library) that saying that new book was added to the author.
So I (system) send a notification to all users who subscribed to receive notifications about this author.
It's unrealistic to create a group for each author ,there are thousands of them, so I need to send just to specific user.

Creating temporary group , sending to everyone in it and then deleting it is very ugly work around.

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
6 years 1 month ago #307476 by slabbi
Use sendNewMessage() instead.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

6 years 1 month ago - 6 years 1 month ago #307477 by Quark Zimmerman
Replied by Quark Zimmerman on topic Bug in uddeIm API when you want to send message to user
Thanks again,
But how I make this message sent from "System" ? If I just set sender "0" it arrives from "Guest" , which is more or less ok as it woks , but a bit strange for users.
Setting yourself (same from as to) looks a bit better but still bad.
Of course it is possibe to create special account for this but then people might start replying to it... its rather messy businesses , better to be able to send from system.
Last edit: 6 years 1 month ago by Quark Zimmerman.

Please Log in or Create an account to join the conversation.

  • slabbi
  • slabbi
  • OFFLINE
  • Posts: 3709
  • Thanks: 250
  • Karma: 153
6 years 1 month ago #307488 by slabbi
You are right. That is currently not possible.
You can copy and paste the code into your module and modify it until I provide an updated API.
Maybe I will add a new parameter that allows to distinguish between users and groups in $recipients.

uddeIM & uddePF Development
CB Language Workgroup
CB 3rd Party Developer

Please Log in or Create an account to join the conversation.

Moderators: beatnantslabbikrileon
Powered by Kunena Forum