public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
        {
            //Admins iq

            //New member
            MucRoomMember member = Room.GetRealMember(iq.From);

            if (member != null)
            {
                if (iq.Query != null)
                {
                    if (iq.Query is Admin && (member.Affiliation == Affiliation.admin || member.Affiliation == Affiliation.owner))
                    {
                        Room.AdminCommand(iq, member);
                    }
                    else if (iq.Query is Owner && (member.Affiliation == Affiliation.owner))
                    {
                        Room.OwnerCommand(iq, member);
                    }
                    else if (iq.Query is Core.protocol.x.tm.history.History && iq.Type == IqType.get)
                    {
                        Jid jid        = iq.To;
                        var mucStore   = new DbMucStore();
                        var properties = new Dictionary <string, string>(1)
                        {
                            { "connectionStringName", "core" }
                        };
                        mucStore.Configure(properties);

                        var history = (Core.protocol.x.tm.history.History)iq.Query;

                        foreach (var msg in mucStore.GetMucMessages(jid, history.Count, history.StartIndex))
                        {
                            if (msg == null)
                            {
                                continue;
                            }

                            history.AddChild(HistoryItem.FromMessage(msg));
                        }
                        iq.Type = IqType.result;
                        iq.SwitchDirection();
                        return(iq);
                    }
                    else
                    {
                        XmppStanzaError.ToForbidden(iq);
                    }
                }
                else
                {
                    XmppStanzaError.ToBadRequest(iq);
                }
            }
            else
            {
                XmppStanzaError.ToForbidden(iq);
            }
            if (!iq.Switched)
            {
                iq.SwitchDirection();
            }
            iq.From = Room.Jid;
            return(iq);
        }
Beispiel #2
0
 public DbMucStoreTest()
 {
     store = new DbMucStore();
     store.Configure(GetConfiguration());
 }