Example #1
0
        /// <summary>
        /// Retrieves a message from the mailbox by unique message ID.
        /// </summary>
        /// <param name="uniqueID">The unique ID of the message to retrieve.</param>
        /// <returns>A <see cref="CmoMessage"/> representing the requested message if found; otherwise, null.</returns>
        /// <remarks>Retrieving the message will also mark it as "opened".</remarks>
        public CmoMessage OpenMessage(string uniqueID)
        {
            CmoMessage message = CmoMessage.GetMessage(uniqueID);

            if (message != null)
            {
                // BUGFIX #52: Fixed loophole where other campaign users can mark other campaigns' unread messages as "open", by adding a check to see if the candidate ID context matches before opening a message in a mailbox.
                if (!string.IsNullOrEmpty(this.Username) && message.IsPosted && _electionCycles.Contains(message.ElectionCycle) && string.Equals(message.CandidateID, _candidateID, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (message.Open(this.Username))
                    {
                        return(message);
                    }
                }
            }
            return(null);
        }