public async Task <bool> DeleteBuddy([FromBody] BuddyLookup lookupData) { bool success = false; //check if buddy is added to list //if not, check for request //if not, throw exception var from_profile = (await profileRepository.Lookup(lookupData.SourceProfile)).First(); var to_profile = (await profileRepository.Lookup(lookupData.TargetProfile)).First(); var items = await buddyRepository.Lookup(lookupData); if (items.Count() <= 0) { if (buddyRepository.DeleteBuddyRequest(from_profile, to_profile) && (!lookupData.silent.HasValue || (lookupData.silent.HasValue && lookupData.silent.Value))) { //TODO: check if offline... add to redis to resend when user logs in await buddyRepository.Delete(lookupData); //delete just in case success = true; } throw new ArgumentException(); } if (success == false) { success = await buddyRepository.Delete(lookupData); } if (success) { buddyRepository.SendDeleteEvent(from_profile, to_profile); } return(success); }
public async Task CreateAuthorizeAdd([FromBody] BuddyLookup lookupData) { var from_profile = (await profileRepository.Lookup(lookupData.SourceProfile)).First(); var to_profile = (await profileRepository.Lookup(lookupData.TargetProfile)).First(); bool status_update = await buddyRepository.AuthorizeAdd(from_profile, to_profile); /*if (status_update) * { * await presenceProfileStatusRepository.SendStatusUpdate(from_profile); * }*/ }
public async Task <bool> DeleteBlock([FromBody] BuddyLookup lookupData) { bool delete_status = await blockRepository.Delete(lookupData); if (delete_status) { var from_profile = (await profileRepository.Lookup(lookupData.SourceProfile)).First(); var to_profile = (await profileRepository.Lookup(lookupData.TargetProfile)).First(); blockRepository.SendDeleteEvent(from_profile, to_profile); } return(delete_status); }
public async Task PutBlock([FromBody] BuddyLookup lookupData) { var from_profile = (await profileRepository.Lookup(lookupData.SourceProfile)).First(); var to_profile = (await profileRepository.Lookup(lookupData.TargetProfile)).First(); Block block = new Block(); block.FromProfileid = from_profile.Id; block.ToProfileid = to_profile.Id; await blockRepository.Create(block); blockRepository.SendAddEvent(from_profile, to_profile); }
public async Task <IEnumerable <PresenceProfileStatus> > Lookup(PresenceProfileLookup lookup) { var is_buddy_lookup = lookup.buddyLookup.HasValue && lookup.buddyLookup.Value; var is_block_lookup = lookup.blockLookup.HasValue && lookup.blockLookup.Value; var is_reverse_lookup = lookup.reverseLookup.HasValue && lookup.reverseLookup.Value; var from_profile = (await this.profileRepository.Lookup(lookup.profileLookup)).FirstOrDefault(); if (from_profile == null) { throw new NoSuchUserException(); } List <PresenceProfileStatus> list = new List <PresenceProfileStatus>(); PresenceProfileStatus status = new PresenceProfileStatus(); if (!is_buddy_lookup && !is_block_lookup) { list.Add(await GetStatusFromProfile(from_profile)); } else if (is_buddy_lookup) { BuddyLookup buddyLookup = new BuddyLookup(); buddyLookup.SourceProfile = lookup.profileLookup; if (lookup.targetLookup != null) { buddyLookup.TargetProfile = lookup.targetLookup; } var buddies = (await this.buddyLookup.Lookup(buddyLookup)); foreach (var buddy in buddies) { list.Add(await GetStatusFromProfile(buddy.ToProfile)); } } else if (is_block_lookup) { BuddyLookup buddyLookup = new BuddyLookup(); buddyLookup.SourceProfile = lookup.profileLookup; var buddies = (await this.blockLookup.Lookup(buddyLookup)); foreach (var buddy in buddies) { list.Add(await GetStatusFromProfile(buddy.ToProfile)); } } return(list); }
public async Task <List <Profile> > GetBlocks([FromBody] BuddyLookup lookupData) { var blocks = (await blockRepository.Lookup(lookupData)).ToList(); List <Profile> profiles = new List <Profile>(); for (int i = 0; i < blocks.Count; i++) { if (lookupData.reverseLookup.HasValue && lookupData.reverseLookup.Value) { profiles.Add(blocks[i].FromProfile); } else { profiles.Add(blocks[i].ToProfile); } } return(profiles); }
public async Task PutBuddy([FromBody] BuddyLookup lookupData) { await buddyRepository.SendBuddyRequest(lookupData); }