Smack Error not-authorized(401) - xmpp

I'm working with smack to create a chat room for my web site but as I want to change a rooms configuration or its members, when I want to get i'ts current members or just doing any other modification, I get Error not-authorized(401)!I'm connected with an administrator account which is the owner of the room too! by the way I can do all these jobs through a client with out any problem!
any body has any Idea How can I fix it?
Regards.

I just found the problem :) it was because I should have joined the room first and then I could manage it!
like this :
MultiUserChat room = new MultiUserChat(connection, roomId);
room.join("admin"); // missing line :)
Collection<Affiliate> currentMembers=room.getMembers();

Related

How can i make a plugin execute a command from another plugin?

i need help in developing pretty simple plugin for miencraft version 1.15.2
Plugin is made to check if user has allready logged for a first time if not:
i adds him to a hashmap (so it wont check him twice) and executes a command on a player to add give him permission from plugin LuckPerms.
I've found out that there is PluginCommand:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/command/PluginCommand.html
But im not quite sure how to use it to make it perform (as server):
/lp user playerName group add groupname
EDIT:
I just can't find how to execute a command so the player will get the permission.
Thanks for your time.
Get luckperms or permissions ex to manage permissions
in your use case the LuckPerms API would make sense to me.
You could use the API to set the Rank of the player loggin in.
LuckPerms api = LuckPermsProvider.get();
api.getUserManager().getUser(uuid).setPrimaryGroup("groupname");
For more info check the Wiki

error: Failed to run the post merge process

I'm trying to generate documents using conga composer 8 from apex code but its failing with error Failed to run the post-merge process. I have looked into url and its same as the one I used initially in another salesforce org. I couldn't find any help online or on conga-composer form.
Here is my conga endpoint URL:
https://composer.congamerge.com/Composer8/Index.Html? sessionId=00D41000000dorw!ARQAQKbinH5TXMR_70s3XCShQh5GuSVdrFcq0Fg9OidZLo9MLxzWSby8QY1B4xM8e72DPawVziclnXBjTzpG41RiCAPKQqOt
&serverUrl=https://na35.salesforce.com/services/Soap/u/29.0/00D41000000dorwEAA
&id=a1J410000012BwS
&TemplateId=a0C41000000kg5GEAQ
&APIMODE=13
&ESAgreementName=Contract+for+Test
&queryid=a0441000001PwI7AAK,a0441000001PwICAA0
&ESSignatureType=2
&ESSignatureOrder=2
&ESVisible=1
&ESCustomField=cldocgen__App__c
&ESCustomFieldValue=a1J410000012BwSEAU
&ESRecipient1=00541000000Ke9pAAC
&ESRecipient2=003410000078zVbAAI
&ESRecipient3=003410000078zVhAAI, Method=GET]
Any insight what might be causing this issue.
I had the same problem and was able to solve it using permissions. In this case make sure the user id whose sessionID is passing to Conga has the correct CRUD access to the primary object in your conga call (id=a1J410000012BwS). My guess is that this is something to do with Conga not being able to write the attachment back to salesforce.
Apart from what Greg has mentioned, there are 2 more observations for this error:
Under Email Administration -> Deliverability -> Access to Send Email (All Email Services) should be set to All email.
In case you are using the EmailTemplateId parameter then the classic email template must be available for use.
Also mostly this error is also because of some discrepancy in the URL.

Smack MultiUserChatManager creates not joinable room

I am using Smack 4.1.1 as Gradle dependency in mine Android project.
I have successfully established connection with mine local OpenFire server.
But I have an issue while creating temporary room from Android client.
final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
try {  
multiUserChat.create(connection.getUser());  
LOG.debug("room created");  
} catch (XMPPException.XMPPErrorException | SmackException e) {  
LOG.error("create room error:{}", e);  
}  
try{  
multiUserChat.sendConfigurationForm(new Form(DataForm.Type.submit));   
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {  
LOG.error("sending room configurations error:{}", e);  
}   
The most great thing is that I can see that room was created in OpenFire admin panel and get room information from another client.
try {  
MultiUserChatManager userChatManager = MultiUserChatManager.getInstanceFor(connection);  
RoomInfo info = userChatManager.getRoomInfo(roomId);  
LOG.debug("room has {} occupants", info.getOccupantsCount());  
joinToExistingRoom(roomId);  
} catch (XMPPException.XMPPErrorException e) {  
LOG.error("join room error:{}", e);  
final XMPPError.Condition condition = e.getXMPPError().getCondition();  
if (condition == XMPPError.Condition.item_not_found) {  
LOG.error("room does not exist error:{}", e);  
createRoom(roomId);  
}  
}  
But while trying to join room from second client I receive XMPPError: recipient-unavailable - wait.
Snippet of mine joinRoom method:
final MultiUserChat multiUserChat = userChatManager.getMultiUserChat(roomId);  
try {  
multiUserChat.join(connection.getUser());  
LOG.debug("joined to room:{}", roomId);  
} catch (SmackException.NoResponseException  
| XMPPException.XMPPErrorException  
| SmackException.NotConnectedException e) {  
LOG.error("error joining room {}", e);  
}  
So I am catching error joining room org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError:recipient-unavailable - wait
So the question is what can be wrong?
I also tried creating submitForm from createAnswerForm() method. But the result is the same.
One solution I have found to make it work is to send persistantroom as true in Answer of configuration form. But this method creates persistent room, though I need this room to be destroyed after all attendees leave room.
Maybe it is a simple problem, but now I do not know how to solve this issue.
Help will be appreciated a lot.
Thanks in advance.
The create() method documentation states that:
Creates the room according to some default configuration, assign the requesting user as the room owner, and add the owner to the room but not allow anyone else to enter the room (effectively "locking" the room). The requesting user will join the room under the specified nickname as soon as the room has been created.
To create an "Instant Room", that means a room with some default configuration that is available for immediate access, the room's owner should send an empty form after creating the room.
Try to send configuration form this way:
multiUserChat.create(connection.getUser())
Form form = new Form(DataForm.Type.submit);
multiUserChat.sendConfigurationForm(form);
See also muc extension documentation

Error creating room using Smack: "Feature not implemented"

I'm following the documentation and trying to create a room:
//Create a MultiUserChat using a Connection for a room
MultiUserChat muc = new MultiUserChat(conn1, "myroom#mycompany.com");
// Create the room
muc.create("testroom");
// Send an empty room configuration form which indicates that we want
// an instant room
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
When I go into PSI, click service discovery, click multiuserchat, right click browse, click myroom. It pops an error message, that says "There was an error getting agents for myroom#mycompany.com, Reason: Feature not implemented. The feature requested is not implemented by the recipient server and cannot be processed".
Any suggestions, anyone?
Now I can create a new room using PSI. I also tried muc.join instead of muc.create. Same error message.
Without knowing your exact setup, I would guess that your room name (myroom#mycompany.com) is incorrect. You get a Feature not implemented because the XMPP entity mycompany.com does likely not act as MUC service. Those are implemented as separate XMPP component, usually named conference or muc, e.g. conference.mycompany.com.

Access muc roster from an ejabberd module (disco_items?)

I'm building an ejabberd module to send carbon copies of messages to an external RESTful API. Everything works okay, and requests to that API are sending POST params with Sender, Recipient and the message Body.
I'm triggering the user_send_packet and user_receive_packet hooks for this, and I can extract the params (Sender, Recipient, Body) from the packet:
Sender = xml:get_tag_attr_s("from", Packet),
Recipient = xml:get_tag_attr_s("to", Packet),
Body = xml:get_path_s(Packet, [{elem, "body"}, cdata])
For group chats (MUC) I'd also like to send the MUC roster (participants) in a parameter, but I don't know how to access them.
Is there an event for this? Can anyone point me to some documentation?
Thanks in advance!
It seems that you want to get MUC participants of specific room.
You need to look at mod_muc.erl and mod_muc_room.erl.
I'm not sure which version of ejabberd you use, so I will explain based on latest ejabberd.
After getting pid of room by calling
mnesia:dirty_read(muc_online_room, {Room, Host})
you can call
gen_fsm:sync_send_all_state_event(Pid, {get_disco_item, From, Lang}, 100)
or use similar code. User list is in the reply.
If you don't like reply format, you may want to add custom handle_sync_event to mod_muc_room.erl .