private void RetriveStatusHyperlinks(StatusViewModel status)
{
var linkMatches = BlipRegExp.Link.Matches(status.Content);
if (linkMatches.Count > 0)
{
for (int i = 0; i < linkMatches.Count; i++)
{
var url = linkMatches[i].Value;
int index = url.LastIndexOf("/");
int indexOfHash = url.IndexOf("#", index);
//code to co mamy na końcu linka albo w rdir.pl/code lub blip.pl/s/code
string code;
if (indexOfHash > index)
{
int len = indexOfHash - 1 - index;
code = url.Substring(index + 1, len);
}
else
{
code = url.Substring(index + 1);
}
if (url.Contains("blip.pl"))
{
if (status.StatusType.ToLower() == "notice" && BlipRegExp.SayOrCite.IsMatch(status.Content))
{
status.StatusId = Convert.ToUInt32(code);
}
//gdy mamy do czynienia z blipnięciem cytowaniem
//http://blip.pl/s/11552391
BlipStatus blpStat = blpCom.GetUpdate(code);
if (blpStat != null)
{
if (status.Cites == null)
{
status.Cites = new Dictionary<string, string>();
}
string blipContent = blpStat.User.Login + ": " + blpStat.Content;
status.Cites.Add(url, blipContent);
}
}
else if (url.Contains("rdir.pl"))
{
string originalLink = blpCom.GetShortLink(code);
if (!string.IsNullOrEmpty(originalLink))
{
//url skrócony
if (status.Links == null)
{
status.Links = new Dictionary<string, string>();
}
status.Links.Add(url, originalLink);
}
}
else
{
if (status.Links == null)
{
status.Links = new Dictionary<string, string>();
}
//url nie skrócony np. do youtube.com
status.Links.Add(url, url);
}
}
}
}