Skip to content

Commit

Permalink
Socioboard 3.0.53
Browse files Browse the repository at this point in the history
Socioboard 3.0.53
  • Loading branch information
Sathish-Globussoft committed Nov 20, 2018
1 parent 9e28abc commit d7517f4
Show file tree
Hide file tree
Showing 131 changed files with 7,334 additions and 3,915 deletions.
87 changes: 44 additions & 43 deletions src/Api.Socioboard/Controllers/FacebookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.AspNetCore.Cors;
using Domain.Socioboard.Models.Mongo;
using MongoDB.Bson;
using Newtonsoft.Json.Linq;

// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

Expand Down Expand Up @@ -52,7 +53,7 @@ public IActionResult AddFacebookAccount(string accessToken, long groupId, long u
dynamic profile = FbUser.getFbUser(accessToken);
try
{
string x = Convert.ToString(profile);
string x = Convert.ToString(profile);
_logger.LogError(x);
}
catch { }
Expand All @@ -63,7 +64,7 @@ public IActionResult AddFacebookAccount(string accessToken, long groupId, long u
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
Domain.Socioboard.Models.Facebookaccounts fbacc = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(Convert.ToString(profile["id"]), _redisCache, dbr);
List<Domain.Socioboard.Models.Groupprofiles> grpProfiles = Api.Socioboard.Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);



//if (grpProfiles.First().profileId == fbacc.FbUserId)
Expand Down Expand Up @@ -118,7 +119,7 @@ public IActionResult ReconnectFbAccount(string accessToken, long groupId, long u
Domain.Socioboard.Models.Facebookaccounts fbaccw = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(profileId, _redisCache, dbr);
//fbacc = fbacc.Where(t => t.FbUserId.Contains("127471161024815")).ToList();

try
try
{
if (fbacc.FbUserId == profileId)
{
Expand All @@ -134,21 +135,21 @@ public IActionResult ReconnectFbAccount(string accessToken, long groupId, long u
int res = Api.Socioboard.Repositories.FacebookRepository.ReFacebookAccount(profile, FbUser.getFbFriends(accessToken), dbr, userId, ngrp.id, Domain.Socioboard.Enum.FbProfileType.FacebookProfile, accessToken, reconnect, _redisCache, _appSettings, _logger);
if (res == 1)
{

MongoRepository repofb = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings);
try
{
var result = repofb.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.profileId == fbacc.FbUserId );
var result = repofb.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.profileId == fbacc.FbUserId);
var task = Task.Run(async () =>
{
return await result;
});
int count = task.Result.Count;

IList<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstFbFeeds = task.Result;
if(count>0)
if (count > 0)
{
FilterDefinition<BsonDocument> filter = new BsonDocument("profileId", lstFbFeeds.FirstOrDefault().profileId);
FilterDefinition<BsonDocument> filter = new BsonDocument("profileId", lstFbFeeds.FirstOrDefault().profileId);
var update = Builders<BsonDocument>.Update.Set("status", true);
repofb.Update<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(update, filter);

Expand Down Expand Up @@ -180,8 +181,8 @@ public IActionResult ReconnectFbAccount(string accessToken, long groupId, long u
{
return Ok("Oops! login information is wrong , login the profile which has to be reconnected");
}



return Ok();

Expand Down Expand Up @@ -316,7 +317,7 @@ public IActionResult GetTopFeeds(string profileId, long userId, int skip, int co
List<Domain.Socioboard.Models.Mongo.facebookfeed> lstfacebookfeed = new List<Domain.Socioboard.Models.Mongo.facebookfeed>();
MongoRepository mongorepo = new MongoRepository("MongoFacebookFeed", _appSettings);
var builder = Builders<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>.Sort;
var sort = builder.Descending(t => t.EntryDate);
var sort = builder.Descending(t => t.EntryDate);
var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>(t => t.ProfileId.Equals(profileId), sort, skip, count);
var task = Task.Run(async () =>
{
Expand Down Expand Up @@ -348,32 +349,32 @@ public IActionResult GetTopFeeds(string profileId, long userId, int skip, int co
}

[HttpGet("GetLatestFeeds")]
public IActionResult GetLatestFeeds(string profileId, long userId, int skip, int count,string date)
public IActionResult GetLatestFeeds(string profileId, long userId, int skip, int count, string date)
{
DateTime lastfeeddate =Convert.ToDateTime(date);
DateTime currentdate = DateTime.UtcNow;
//Int32 unixTimestamp= Convert.ToInt32(date);
List<Domain.Socioboard.Models.Mongo.facebookfeed> lstfacebookfeed = new List<Domain.Socioboard.Models.Mongo.facebookfeed>();
MongoRepository mongorepo = new MongoRepository("MongoFacebookFeed", _appSettings);
var builder = Builders<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>.Sort;
var sort = builder.Descending(t => t.EntryDate);
var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>(t => t.ProfileId.Equals(profileId), sort, skip, count);
var task = Task.Run(async () =>
{
return await result;
});
IList<Domain.Socioboard.Models.Mongo.MongoFacebookFeed> lstFbFeeds = task.Result;
List<Domain.Socioboard.Models.Mongo.LatestFacebookFeed> lstlatestfeed = new List<Domain.Socioboard.Models.Mongo.LatestFacebookFeed>();
lstlatestfeed = lstFbFeeds.Select(x => new LatestFacebookFeed() { EntryDate = Convert.ToDateTime(x.EntryDate), FeedDescription = x.FeedDescription, FeedDate=x.FeedDate, ProfileId=x.ProfileId, FromId=x.FromId, FromName=x.FromName, FromProfileUrl=x.FromProfileUrl, Type=x.Type, FbComment=x.FbComment, FbLike=x.FbLike, FeedId=x.FeedId, ReadStatus=x.ReadStatus, Picture=x.Picture, Positive=x.Positive, Negative=x.Negative, Commentcount=x.Commentcount, Likecount=x.Likecount, postType=x.postType, postingFrom=x.postingFrom, _facebookComment=x._facebookComment }).ToList();
lstlatestfeed=lstlatestfeed.FindAll(t => t.EntryDate > lastfeeddate && t.EntryDate <= currentdate).ToList();
return Ok(lstlatestfeed.ToList());
DateTime lastfeeddate = Convert.ToDateTime(date);
DateTime currentdate = DateTime.UtcNow;
//Int32 unixTimestamp= Convert.ToInt32(date);
List<Domain.Socioboard.Models.Mongo.facebookfeed> lstfacebookfeed = new List<Domain.Socioboard.Models.Mongo.facebookfeed>();
MongoRepository mongorepo = new MongoRepository("MongoFacebookFeed", _appSettings);
var builder = Builders<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>.Sort;
var sort = builder.Descending(t => t.EntryDate);
var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>(t => t.ProfileId.Equals(profileId), sort, skip, count);
var task = Task.Run(async () =>
{
return await result;
});
IList<Domain.Socioboard.Models.Mongo.MongoFacebookFeed> lstFbFeeds = task.Result;
List<Domain.Socioboard.Models.Mongo.LatestFacebookFeed> lstlatestfeed = new List<Domain.Socioboard.Models.Mongo.LatestFacebookFeed>();
lstlatestfeed = lstFbFeeds.Select(x => new LatestFacebookFeed() { EntryDate = Convert.ToDateTime(x.EntryDate), FeedDescription = x.FeedDescription, FeedDate = x.FeedDate, ProfileId = x.ProfileId, FromId = x.FromId, FromName = x.FromName, FromProfileUrl = x.FromProfileUrl, Type = x.Type, FbComment = x.FbComment, FbLike = x.FbLike, FeedId = x.FeedId, ReadStatus = x.ReadStatus, Picture = x.Picture, Positive = x.Positive, Negative = x.Negative, Commentcount = x.Commentcount, Likecount = x.Likecount, postType = x.postType, postingFrom = x.postingFrom, _facebookComment = x._facebookComment }).ToList();
lstlatestfeed = lstlatestfeed.FindAll(t => t.EntryDate > lastfeeddate && t.EntryDate <= currentdate).ToList();
return Ok(lstlatestfeed.ToList());

}

[HttpGet("GetTopFilterFeeds")]
public IActionResult GetTopFilterFeeds(string profileId, long userId, int skip, int count, string typeFilter)
{
return Ok(Repositories.FacebookRepository.GetTopFacebookFilterFeed(profileId, userId, _redisCache, _appSettings, skip, count, typeFilter));
return Ok(Repositories.FacebookRepository.GetTopFacebookFilterFeed(profileId, userId, _redisCache, _appSettings, skip, count, typeFilter));
}


Expand Down Expand Up @@ -501,8 +502,8 @@ public IActionResult AddFacebookPages(long userId, long groupId)
int invalidaccessToken = 0;
foreach (var item in accesstoken)
{
dynamic profile = Fbpages.getFbPageData(item);
string subscribed_apps = Fbpages.subscribed_apps(item, Convert.ToString(profile["id"]));
dynamic profile = Fbpages.GetFbPageData(item);
FacebookApiHelper.MakeSubscribedWithApp(item);
try
{
string x = Convert.ToString(profile);
Expand All @@ -514,10 +515,10 @@ public IActionResult AddFacebookPages(long userId, long groupId)
invalidaccessToken++;
// return Ok("Invalid Access Token");
}
else
else
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
Domain.Socioboard.Models.Facebookaccounts fbacc = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(Convert.ToString(profile["id"]), _redisCache, dbr);
Domain.Socioboard.Models.Facebookaccounts fbacc = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(Convert.ToString(profile["id"]), _redisCache, dbr);
if (fbacc != null && fbacc.IsActive == true)
{
addedPageCount++;
Expand All @@ -533,18 +534,18 @@ public IActionResult AddFacebookPages(long userId, long groupId)
// Adding Facebook Page
int res = Api.Socioboard.Repositories.FacebookRepository.AddFacebookPage(profile, dbr, userId, ngrp.id, Domain.Socioboard.Enum.FbProfileType.FacebookPage, item, _redisCache, _appSettings, _logger);

}
}
}
}
if (addedPageCount == accesstoken.Length)
{
return Ok("Facebook Pages added by other user.");
}
else if(addedPageCount == accesstoken.Length)
else if (addedPageCount == accesstoken.Length)
{
return Ok("Facebook Pages having Invalid Access Token.");
}
else if (invalidaccessToken > 0 && addedPageCount>0)
else if (invalidaccessToken > 0 && addedPageCount > 0)
{
return Ok("Pages added successfully and " + addedPageCount + " pages added by other user or " + invalidaccessToken + " pages having invalid access token issue");
}
Expand Down Expand Up @@ -591,7 +592,7 @@ public IActionResult ReconnFacebookPages(long userId, long groupId, string acces


int invalidaccessToken = 0;
dynamic profile = Fbpages.getFbPageData(accessToken);
dynamic profile = Fbpages.GetFbPageData(accessToken);
string subscribed_apps = Fbpages.subscribed_apps(accessToken, Convert.ToString(profile["id"]));
try
{
Expand All @@ -607,8 +608,8 @@ public IActionResult ReconnFacebookPages(long userId, long groupId, string acces
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
Domain.Socioboard.Models.Facebookaccounts fbacc = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(Convert.ToString(profile["id"]), _redisCache, dbr);
int isSaved = 0;

int isSaved = 0;
if (fbacc != null)
{
fbacc.IsActive = true;
Expand All @@ -624,15 +625,15 @@ public IActionResult ReconnFacebookPages(long userId, long groupId, string acces
}
try
{
fbacc.coverPic = (Convert.ToString(profile["cover"]["source"]));
fbacc.CoverPic = (Convert.ToString(profile["cover"]["source"]));
}
catch (Exception)
{

}
fbacc.AccessToken = accessToken;
isSaved = dbr.Update<Domain.Socioboard.Models.Facebookaccounts>(fbacc);
if (isSaved>0)
if (isSaved > 0)
{
return Ok("Page Reconnected Successfully");
}
Expand All @@ -653,7 +654,7 @@ public IActionResult GetFacebookPostComment(string postId)
}

[HttpPost("PostFacebookComment")]
public IActionResult PostFacebookComment(string postId, string profileId, string message,string timezoneOffset)
public IActionResult PostFacebookComment(string postId, string profileId, string message, string timezoneOffset)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string postcomment = Repositories.FacebookRepository.PostFacebookComment(dbr, message, profileId, postId, timezoneOffset, _redisCache, _appSettings, _logger);
Expand Down
29 changes: 22 additions & 7 deletions src/Api.Socioboard/Controllers/GoogleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public GoogleController(ILogger<UserController> logger, IEmailSender emailSender
///
/// </summary>
/// <param name="code"></param>
/// <returns></returns
/// <param name="accType"></param>
/// <returns></returns>
[HttpPost("GoogleLogin")]
public IActionResult GoogleLogin(string code,Domain.Socioboard.Enum.SBAccountType accType)
{
Expand Down Expand Up @@ -251,19 +252,19 @@ public IActionResult GoogleLogin(string code,Domain.Socioboard.Enum.SBAccountTyp
catch { }
user.RegistrationType = Domain.Socioboard.Enum.SBRegistrationType.Google;

int SavedStatus = dbr.Add<Domain.Socioboard.Models.User>(user);
var savedStatus = dbr.Add<Domain.Socioboard.Models.User>(user);
User nuser = dbr.Single<User>(t => t.EmailId.Equals(user.EmailId));
if (SavedStatus == 1 && nuser != null)
if (savedStatus == 1 && nuser != null)
{
Groups group = new Groups();
group.adminId = nuser.Id;
group.createdDate = DateTime.UtcNow;
group.groupName = Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName;
SavedStatus = dbr.Add<Groups>(group);
if (SavedStatus == 1)
savedStatus = dbr.Add<Groups>(group);
if (savedStatus == 1)
{
Groups ngrp = dbr.Find<Domain.Socioboard.Models.Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).FirstOrDefault();
GroupMembersRepository.createGroupMember(ngrp.id, nuser, _redisCache, dbr);
GroupMembersRepository.CreateGroupMember(ngrp.id, nuser, _redisCache, dbr);
// Adding GPlus Profile
Api.Socioboard.Repositories.GplusRepository.AddGplusAccount(userinfo, dbr, nuser.Id, ngrp.id, access_token, refreshToken, _redisCache, _appSettings, _logger);
}
Expand All @@ -276,6 +277,13 @@ public IActionResult GoogleLogin(string code,Domain.Socioboard.Enum.SBAccountTyp

}

/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <param name="GplusId"></param>
/// <param name="checkEnable"></param>
/// <returns></returns>
[HttpPost("EnableDisableGoogleSignIn")]
public IActionResult EnableDisableGoogleSignIn(long userId,string GplusId, bool checkEnable)
{
Expand Down Expand Up @@ -350,6 +358,13 @@ public IActionResult GetGplusProfilesOnly(long groupId)
return Ok(lstGplusAcc);
}

/// <summary>
///
/// </summary>
/// <param name="refreshToken"></param>
/// <param name="accessToken"></param>
/// <param name="accType"> Pass a enum of <see cref="Domain.Socioboard.Enum.SBAccountType"/></param>
/// <returns></returns>
[HttpPost("GoogleLoginPhone")]
public IActionResult GoogleLoginPhone(string refreshToken,string accessToken, Domain.Socioboard.Enum.SBAccountType accType)
{
Expand Down Expand Up @@ -493,7 +508,7 @@ public IActionResult GoogleLoginPhone(string refreshToken,string accessToken, Do
if (SavedStatus == 1)
{
Groups ngrp = dbr.Find<Domain.Socioboard.Models.Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).FirstOrDefault();
GroupMembersRepository.createGroupMember(ngrp.id, nuser, _redisCache, dbr);
GroupMembersRepository.CreateGroupMember(ngrp.id, nuser, _redisCache, dbr);
// Adding GPlus Profile
Api.Socioboard.Repositories.GplusRepository.AddGplusAccount(userinfo, dbr, nuser.Id, ngrp.id, accessToken, refreshToken, _redisCache, _appSettings, _logger);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Api.Socioboard/Controllers/GroupsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IActionResult CreateGroup(Domain.Socioboard.Models.Groups group)
{
Domain.Socioboard.Models.User user = dbr.FindSingle<User>(t => t.Id == group.adminId);
long GroupId = dbr.FindSingle<Domain.Socioboard.Models.Groups>(t => t.adminId == group.adminId && t.groupName.Equals(group.groupName)).id;
GroupMembersRepository.createGroupMember(GroupId, user, _redisCache, dbr);
GroupMembersRepository.CreateGroupMember(GroupId, user, _redisCache, dbr);
_redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + group.adminId);
return Ok("Team Added Successfully ");
}
Expand Down
Loading

0 comments on commit d7517f4

Please sign in to comment.