Пример #1
0
        private SysGroup TryLookupSystemGroup(Murmur.ACL x)
        {
            // Keep this wrapper because I'm lazy and didn't implement ALL system groups
            SysGroup res;

            if (SysGroups.TryGetValue(x.group, out res))
            {
                return(res);
            }
            throw new Exception(String.Format("Group not found: '{0}'", x.group));
        }
Пример #2
0
        Task IReadModifyWriteObject.SaveChanges()
        {
            // Validate that all referenced groups are there.
            // (race condition but fine as this is just a convenience validation)
            // (btw, you could also just implement custom group objects to trick this check)
            if (!ACL.Cast <ChanACL>().All(x => x.TargetGroup == null || SysGroups.Values.Contains(x.TargetGroup) ||
                                          Groups.Concat(InheritedGroups).Any(y => y.Name == ((ChanGroup)x.TargetGroup).Name)))
            {
                throw new InvalidOperationException("Referencing groups that weren't added!");
            }

            return(Server.SetACL(ChannelId, new Wrapped.Server.ACLData
            {
                Inherit = Inherit,
                ACLs = ACL.Select(x => new Murmur.ACL
                {
                    allow = (int)x.Allow,
                    deny = (int)x.Deny,
                    applyHere = x.ApplyOnThisChannel,
                    applySubs = x.ApplyOnSubchannels,
                    userid = x.TargetUser ?? -1,
                    group = x.TargetGroup == null ? String.Empty :
                            (x.TargetGroup is ChanGroup ? ((ChanGroup)x.TargetGroup).Name : SysGroups.Single(y => y.Value == x.TargetGroup).Key),
                }).ToArray(),
                Groups = InheritedGroups.Concat(Groups).Cast <ChanGroup>().Select(x => new Murmur.Group
                {
                    name = x.Name,
                    inherited = x._Inherited,
                    inherit = (x is IChannelUserGroupInherited) ? ((IChannelUserGroupInherited)x).IncludeMembersFromParentChannels : false,
                    inheritable = x.Inheritable,
                    add = x.Members.ToArray(),
                    remove = x.NegativeMembers.ToArray(),
                }).ToArray(),
            }));
        }