Пример #1
0
 private string OtherLinkReplacement(string code)
 {
     return(PythonModel.CreateTinyUrl(code));
 }
Пример #2
0
        private string SpecialLinkReplacement(string code, SMSItem item)
        {
            // remove the non url parts and reformat
            code = code.Replace("\"", string.Empty);
            code = code.Replace("&", "&");
            code = HttpUtility.UrlDecode(code);

            // parse the special link url to get the component parts
            Uri    specialLink = new Uri(code);
            string type        = specialLink.Host;
            var    querystring = HttpUtility.ParseQueryString(specialLink.Query);
            string orgId       = querystring.Get("org");
            string meetingId   = querystring.Get("meeting");
            string groupId     = querystring.Get("group");
            string confirm     = querystring.Get("confirm");
            string message     = querystring.Get("msg");

            // result variables
            string qs;      // the unique link combination for the db

            // set some defaults for any missing properties
            bool showfamily = false;

            if (!message.HasValue())
            {
                message = "Thank you for responding.";
            }
            if (!confirm.HasValue())
            {
                confirm = "false";
            }

            // generate the one time link code and update any vars based on the link type
            switch (type)
            {
            case "rsvplink":
            case "regretslink":
                qs = $"{meetingId},{item.PeopleID},{item.Id},{groupId}";
                break;

            case "registerlink":
            case "registerlink2":
                showfamily = (type == "registerlink2");
                qs         = $"{orgId},{item.PeopleID},{item.Id}";
                break;

            case "sendlink":
            case "sendlink2":
                showfamily = (type == "sendlink2");
                qs         = $"{orgId},{item.PeopleID},{item.Id},{(showfamily ? "registerlink2" : "registerlink")}";
                break;

            case "votelink":
                string pre = "";
                var    a   = groupId.SplitStr(":");
                if (a.Length > 1)
                {
                    pre = a[0];
                }
                qs = $"{orgId},{item.PeopleID},{item.Id},{pre},{groupId}";
                break;

            default:
                return(code);
            }

            var ot  = CreateOrFetchOneTimeLink(qs, oneTimeLinkList);
            var url = CreateUrlForLink(type, ot, confirm, message, showfamily);

            return(PythonModel.CreateTinyUrl(url));
        }