xmpp - how to get room chat history - history

I am using the iOS xmppframework.
I want to get room chat history when needed. Such that there is a button, when click the button, 20 history messages will be received each time.
If I have 100 history messages, I click the button 5 times, then I will get all the history message.
[xmppRoom1 joinRoomUsingNickname:#"myNickname" history:history password:nil];
this method can only used once.

Send history nil
and alos update in openfire
open your openfire url then click on Group chat > Group Chat setting > your group > history setting
XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:#"%##conference.51.101.97.21",groupName]];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
jid:roomJID
dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
history:nil
password:nil];

I use this method, but can receive anything.
NSXMLElement *history = [[NSXMLElement alloc] initWithName:#"history"];
[history addAttributeWithName:#"maxstanzas" stringValue:#"5"];
NSXMLElement *x = [NSXMLElement elementWithName:#"x" xmlns:XMPPMUCNamespace];
if (history)
{
[x addChild:history];
}
XMPPPresence *presence = [XMPPPresence presenceWithType:nil to:xmppRoom1.myRoomJID];
[presence addChild:x];
[xmppStream sendElement:presence];
The message sent and received:
SEND:
<presence to="ios#conference.192.168.1.67/myNickname”>
<x xmlns="http://jabber.org/protocol/muc”>
<history maxstanzas="5”/>
</x>
<x xmlns="vcard-temp:x:update"><photo/></x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=“/>
</presence>
RECV:
<presence xmlns="jabber:client" from="ios#conference.192.168.1.67/myNickname" to="test1#192.168.1.67/14392264591434445057383183”>
<x xmlns="vcard-temp:x:update"><photo/></x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://github.com/robbiehanson/XMPPFramework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=“/>
<x xmlns="http://jabber.org/protocol/muc#user”>
<item jid="test1#192.168.1.67/14392264591434445057383183" affiliation="owner" role="moderator"/><status code="110”/>
</x></presence>

Related

Get stream, System message customisation stream-chat

community
I implemented stream-chat & stream-chat-react getStream
Hi, I want to show the system message on some events
For Ex: User A added User B to the chat (Here user A and User B is the name of both user but I don't want to send those message as it is because I want if user A changes their name to USER X then those previous messages also updated.) I want guidance on how I can achieve this.
Stream is allowing me to send system messages with the addMemberToChannel event but I am not able to find how I can use it for my specific case.
Expected Output:
For your case, you will avoid saving hardcoded data in the message's text property.
First, you create a system message on adding a user to a channel like this:
channel.addMembers([userId], {
text: 'added_users',
mentioned_users: [userId],
});
With the addMembers method on a channel object, you can add members to a channel and also pass a message object.
The message object accepts the message text and the mentioned_users properties.
You can use added_users or any text that you want to keep as a standard message for adding-members-system-message. You'll see why I use "added_users" in a second.
The Channel component renders system messages using the EventComponent. This component displays the text of the system message, with the date and some added styles.
You can create a custom event message component for your added_users message. This component can look like this:
import { EventComponent } from 'stream-chat-react';
function CustomEventMessage(props) {
const { message } = props;
const { text, mentioned_users, user } = message;
if (text === 'added_users') {
const message = user?.name + ' added ' + mentioned_users[0].name;
return (
<div className="str-chat__message--system">
<div className="str-chat__message--system__text">
<div className="str-chat__message--system__line"></div>
<p>{message}</p>
<div className="str-chat__message--system__line"></div>
</div>
</div>
);
}
// use the default event component
return <EventComponent {...props} />;
}
The CustomEventMessage component above accepts a message object prop which has the:
text: system message text
mentioned_users: mentioned users in the message
user: user who triggered the message
Next, you check if the text is added_users. If it is, then you provide a custom UI and message, which consists of the name of the user who triggered the message and the mentioned user (who was added to the channel)
I also used classnames from Stream's stylesheets so that I don't have to build mine.
Next, you add this component to the Channel component:
<Channel MessageSystem={CustomEventMessage}>
// ...
</Channel>
The message will now read as "Person X added Person Y" as seen in the image below:
If the text is not added_users, you pass the props to the default EventComponent.
Since you're saving the id of the mentioned user and not hardcoding the text ("Person A added Person B"), you will also get updated details about the users, even when they update their information.

IBM Domino - meeting document reschedule (in db) chair receives email but doesn't update

I'm running a java XPage rest api that operates on the rooms & resource reservation database. It's executed by a single designated user which has full access to the database.
What I want to do, is to re-schedule someone's else meeting directly via the database. It works when I view it in the database, the meeting is updated successfully, however in the chair's notes client calendar, the meeting still appears as it was, despite receiving an "Accepted: " e-mail with new meeting date (I think it should be "Rescheduled:" though..)
Here's my code that creates a response document & sends it:
DateTime dt_startDateUTC = session.createDateTime(dtStart);
DateTime dt_endDateUTC = session.createDateTime(dtEnd);
Document docNew = reDatabase.createDocument(); // response doc
docAppointment.copyAllItems(docNew, true); // copy items from origianl doc
docNew.replaceItemValue("NoticeType", "U"); // update notice
docNew.replaceItemValue("CalendarDateTime", dt_startDateUTC);
docNew.replaceItemValue("SequenceNum", docAppointment.getItemValueInteger("SequenceNum") + 1); // bump SequenceNum
docNew.replaceItemValue("RmNameUpdated", "");
docNew.replaceItemValue("ResNameUpdated", "");
docNew.replaceItemValue("$RnRVersion", "2");
docNew.replaceItemValue("$CSVersion", "2");
docNew.replaceItemValue("Form", "Notice");
docNew.replaceItemValue("$NoPurge", dt_endDateUTC.getLocalTime());
docNew.replaceItemValue("StartDateTime", dt_startDateUTC);
docNew.replaceItemValue("StartDate", dt_startDateUTC);
docNew.replaceItemValue("StartTime", dt_startDateUTC);
docNew.replaceItemValue("RepeatInstanceDates", dt_startDateUTC);
docNew.replaceItemValue("EndDateTime", dt_endDateUTC);
docNew.replaceItemValue("EndDate", dt_endDateUTC);
docNew.replaceItemValue("EndTime", dt_endDateUTC);
docNew.removeItem("ReserveDate");
docNew.removeItem("step");
docNew.removeItem("$BusyPriority");
docNew.removeItem("$BusyName");
docNew.replaceItemValue("wgcIGNORE", "1");
docNew.replaceItemValue("$CSFlags", "w"); // taken from c&s workflow schema
docNew.replaceItemValue("Form", "Notice");
docNew.replaceItemValue("_ViewIcon", "33");
docNew.makeResponse(docAppointment);
docNew.send();
docNew.save();
docNew.recycle();
In my server log I see:
Router: Message 00325BD6, 0027FEE7 delivered to Room 1/Organization
Router: Message 00325C92 delivered to testuser/Organization
In my user's notes client I can see a new received mail from Room 1 titled "Accepted: Meeting subject" and when I enter it, the dates are correct (rescheduled), but when I click "Open meeting" the meeting still has old dates.
Am I doing something wrong? How can I enforce an update of that meeting? I already tried many different ways but without luck. I cannot modify user's calendar directly because I'd need to assign access to every user's mail database and that wouldn't be secure.

Emails with event invite generated by MVC application not synced with calendar in outlook.com

I am creating ASP.NET MVC5 application. One functionality is to send emails with event invitations. In Gmail client such generated email works fine. But in outlook.com even if the email has correct buttons - accept/tentative/decline - clicking on them won't sync that into the calendar itself.
I took some inspiration here:
StackOverflow Q1
StackOverflow Q2
StackOverflow Q3
Here is my current implementation:
I am using DDay.ical library for creating the event:
IICalendar iCal = new iCalendar();
iCal.Version = "2.0";
iCal.Method = "REQUEST";
iCal.ProductID = "my#product.com";
Event evt = iCal.Create<Event>();
evt.UID = Guid.NewGuid().ToString();
evt.Class = "PUBLIC";
evt.Created = new iCalDateTime(DateTime.Now);
evt.DTStamp = new iCalDateTime(DateTime.Now);
evt.Start = new iCalDateTime(DateTime.Now.AddHours(2));
evt.End = new iCalDateTime(DateTime.Now.AddHours(4));
evt.Location = "Party room";
evt.Description = "Awesome party";
evt.Summary = "Lets get wasted";
evt.Priority = 5;
evt.Transparency = TransparencyType.Transparent;
string res = new iCalendarSerializer().SerializeToString(iCal);
return res;
I am packing this event into email as an alternative view:
MailMessage email = new MailMessage();
email.To.Add(addressesToJoined);
email.Subject = Party;
email.Body = "";
if (!String.IsNullOrEmpty(calendarEvent))
{
System.Net.Mime.ContentType calendarType = new System.Net.Mime.ContentType("text/calendar");
calendarType.Parameters.Add("method", "REQUEST");
AlternateView ICSview = AlternateView.CreateAlternateViewFromString(calendarEvent, calendarType);
email.AlternateViews.Add(ICSview);
}
And here is the .ics itself:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:my#product.com
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20151115T152442
DESCRIPTION:Awesome party
DTEND:20151115T192442
DTSTAMP:20151115T142442Z
DTSTART:20151115T172442
LOCATION:Party room
PRIORITY:5
SEQUENCE:0
SUMMARY:Lets get wasted
TRANSP:Transparent
UID:1735cdca-cb36-4e6b-a1ec-4fb4149f798a
END:VEVENT
END:VCALENDAR
When this email comes to Gmail client, I can correctly see the invitation with option to add event into calendar, which works fine.
But in outlook.com even when the email itself is correctly recognized as invitation and I can see accept/tentative/decline buttons it does not work as expected. When I click for example accept option, new response email is created and when I send it out, I would expect, the event will be set in my calendar, however there is no event synced.
Can someone please see why events are not synced in calendar in outlook.com?
Also, is there possibility in outlook.com to just set event in calendar, without sending response email? - invitations are auto-generated from system no need for response.
Thanks
Finally I've found a solution - there was missing ORGANIZER parameter of the VEVENT part in .ics. Gmail is able to handle that, Outlook.com not. So the trick was to add following line when setting DDay.iCal.Event object:
evt.Organizer = new Organizer("organizer#mail.com");
Everything else remained untouched so the final look of the .ics which works in both - Gmail and Outlook.com is this:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:my#product.com
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20151115T152442
DESCRIPTION:Awesome party
DTEND:20151115T192442
DTSTAMP:20151115T142442Z
DTSTART:20151115T172442
LOCATION:Party room
ORGANIZER:mailto:organizer#email.com
PRIORITY:5
SEQUENCE:0
SUMMARY:Lets get wasted
TRANSP:Transparent
UID:1735cdca-cb36-4e6b-a1ec-4fb4149f798a
END:VEVENT
END:VCALENDAR
Now it works fine.

Share Kit, can't get keyboard up in twitter auth web view

Trying to use share kit to send a link to twitter,and when the webview comes up to log into twitter, you can tap into the username and password fields, get a cursor, but no keyboard pops up.
This is really starting to frustrate me.
Here's how I'm trying to call Share kit. (from an alert)
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView.tag == 21){
if (buttonIndex == 1) {
//call SHK
NSLog(#"Calling SHK");
// Create the item to share (in this example, a url)
NSURL *url = [NSURL URLWithString:#"http://link.com"];
SHKItem *item = [SHKItem URL:url title:[NSString stringWithFormat:#"I just played a %d by %d board on #GAMENAME and solved it in %d moves!", down, across, turns]];
// Get the ShareKit action sheet
[alertView dismissWithClickedButtonIndex:0 animated:NO];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showInView:self.view];
}
}
It was a problem with UIResponder
UIResponder Troubles

UIViewController covering UINavigationBar

I have a UITabBarController with 2 items, where each item is pointing to a view controller of type Navigation Controller.
The second item is a login page to my web service.
A User that did not logged in will see a login page -> "LoginViewController".
If a user is already logged in, a different view will be there -> "LoggedViewController".
On Startup, in my AppDelegate i am checking if the user already logged or need to login and i change the views.
if (!logged) {
LoginViewController * nextView = [[[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil] autorelease];
NSMutableArray * tabBarRootViews = [[NSMutableArray alloc] initWithArray:self.tabBarController.viewControllers];
[tabBarRootViews replaceObjectAtIndex:1 withObject:nextView];
[self.tabBarController setViewControllers:tabBarRootViews animated:YES];
} else {
// Same if the user is logged only diff view
}
When the view is presented, It overlaps the UINavigationBar.
I believe that the issue is that i am trying to replace a UINavigationController with a UIViewController, but i can't put my finger on the problem.
Any idea how to solve it? (I want to see both the UITabBar and UINavigationBar and the UIViewController in the middle)
Is that the correct way to change ViewControllers? Should i Use PresentModalView Instead?
Thanks!
I fixed it by keeping the UINavigationController as is and push a view controller according to the logged boolean.

Resources