Skip to content

Commit

Permalink
socioboard 3.0 update
Browse files Browse the repository at this point in the history
socioboard 3.0 update
  • Loading branch information
swetasb committed Mar 6, 2018
1 parent d8da79d commit 4eb9cf0
Show file tree
Hide file tree
Showing 20 changed files with 1,110 additions and 167 deletions.
9 changes: 9 additions & 0 deletions src/Api.Socioboard/Controllers/FacebookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,5 +724,14 @@ public IActionResult Fbtype(string profileId)
return Ok(Userdata);

}

[HttpGet("GetFbAccSingle")]
public IActionResult GetFbAccSingle(string accId)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
Domain.Socioboard.Models.Facebookaccounts pageDetails = dbr.Single<Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId == accId);
return Ok(pageDetails);
}

}
}
15 changes: 15 additions & 0 deletions src/Api.Socioboard/Controllers/SavedFeedsManagementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,20 @@ public IActionResult GetComments(string postId, long groupId)
{
return Ok(SavedFeedsManagementRepository.GetComments(postId, groupId, _appSettings));
}

[HttpPost("aprove")]
public IActionResult aprove(string strid ,bool update)
{
bool status = SavedFeedsManagementRepository.changeaprove(strid, update, _appSettings);
return Ok(status);
}

//ScheduleMsg
[HttpPost("ScheduleMsg")]
public IActionResult ScheduleMsg(string postId, long groupId ,string schtime)
{
bool status = SavedFeedsManagementRepository.scheduleMsgRepo(postId, groupId, schtime, _appSettings);
return Ok(status);
}
}
}
20 changes: 20 additions & 0 deletions src/Api.Socioboard/Controllers/TwitterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using System.Text.RegularExpressions;
using Domain.Socioboard.Interfaces.Services;
using System.Threading;
using MongoDB.Bson;
using Api.Socioboard.Repositories;

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

Expand Down Expand Up @@ -519,5 +521,23 @@ public IActionResult GettwitterSingle(string profileId)

}

// [HttpPost("publish")]
//public IActionResult publish(string profileId,string twitterText, long userId , string imgUrl ,string strid)
//{
// DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
// string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, profileId, userId, imgUrl, true, 0, "", dbr, _logger);
// if (ret =="")
// {
// string responce = SavedFeedsManagementRepository.publish( profileId, strid, _appSettings);

// return Ok(responce);
// }
// else
// {
// return Ok("failed");
// }


// }
}
}
182 changes: 168 additions & 14 deletions src/Api.Socioboard/Controllers/WebHookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,36 @@ public async Task<HttpResponseMessage> Post()
}
if (x["changes"][0]["value"]["item"] == "comment")
{
_logger.LogInformation("comment section started");

string profileId = Convert.ToString(x["id"]);
_logger.LogInformation("profileId" + profileId);

string sendId = Convert.ToString(x["changes"][0]["value"]["sender_id"]);
_logger.LogInformation("sendId" + sendId);

string sendername = Convert.ToString(x["changes"][0]["value"]["sender_name"]);
_logger.LogInformation("sendId" + sendId);

string like = Convert.ToString(x["changes"][0]["value"]["item"]);
_logger.LogInformation("like" + like);

string postid = Convert.ToString(x["changes"][0]["value"]["post_id"]);
_logger.LogInformation("postid" + postid);

string message = Convert.ToString(x["changes"][0]["value"]["message"]);
_logger.LogInformation("message" + message);

string postTime = Convert.ToString(x["changes"][0]["value"]["created_time"]);
_logger.LogInformation("postTime comment" + postTime);
_logger.LogInformation("postTime Comment" + postTime);

string comment_id = Convert.ToString(x["changes"][0]["value"]["comment_id"]);
_logger.LogInformation("comment_id " + comment_id);

if (!string.IsNullOrEmpty(comment_id))
{
_logger.LogInformation("saving data started");

MongoFbPostComment fbPostComment = new MongoFbPostComment();
fbPostComment.Id = MongoDB.Bson.ObjectId.GenerateNewId();
fbPostComment.EntryDate = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");
Expand All @@ -391,17 +407,94 @@ public async Task<HttpResponseMessage> Post()
string printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
string createddate = Convert.ToDateTime(printDate).ToString("yyyy-MM-dd h:mm tt");
DateTime convertedDate = DateTime.SpecifyKind(DateTime.Parse(createddate), DateTimeKind.Utc);
fbPostComment.Commentdate = convertedDate.ToString();
_logger.LogInformation("commnet date" + fbPostComment.Commentdate);
try
{
fbPostComment.Commentdate = convertedDate.ToString();
_logger.LogInformation("commnet date" + fbPostComment.Commentdate);
}
catch (Exception ex)
{
fbPostComment.Commentdate = " ";
_logger.LogInformation("commnetDate error" + ex.Message);
}


//fbPostComment.Commentdate = DateTime.Parse(postTime).ToString("yyyy/MM/dd HH:mm:ss");
fbPostComment.PostId = postid;
fbPostComment.Likes = 0;
fbPostComment.UserLikes = 0;
fbPostComment.PictureUrl = message;
fbPostComment.FromName = sendername;
fbPostComment.FromId = sendId;
fbPostComment.CommentId = comment_id;
fbPostComment.Comment = message;
try
{
fbPostComment.PostId = postid;
}
catch (Exception ex)
{
fbPostComment.PostId = " ";
_logger.LogInformation("PostId error" + ex.Message);
}
try
{
fbPostComment.Likes = Convert.ToInt16(like);
}
catch(Exception ex)
{
fbPostComment.Likes = 0;
_logger.LogInformation("Likes error" + ex.Message);
}
try
{
fbPostComment.UserLikes = 0;
}
catch(Exception ex)
{
fbPostComment.UserLikes = 0;
_logger.LogInformation("userlikes error" + ex.Message);
}
try
{
fbPostComment.PictureUrl = message;
}
catch(Exception ex)
{
fbPostComment.PictureUrl = " ";
_logger.LogInformation("PictureUrl error" + ex.Message);
}
try
{
fbPostComment.FromName = sendername;
}
catch (Exception ex)
{
fbPostComment.FromName = " ";
_logger.LogInformation("FromName error" + ex.Message);
}

try
{
fbPostComment.FromId = sendId;
}
catch (Exception ex)
{
fbPostComment.FromId = " ";
_logger.LogInformation("FromId error" + ex.Message);
}

try
{
fbPostComment.CommentId = comment_id;
}
catch (Exception ex)
{
fbPostComment.CommentId = " ";
_logger.LogInformation("CommentId error" + ex.Message);
}
try
{
fbPostComment.Comment = message;
}
catch (Exception ex)
{
fbPostComment.Comment = " ";
_logger.LogInformation("CommentId error" + ex.Message);
}

try
{

Expand All @@ -421,25 +514,30 @@ public async Task<HttpResponseMessage> Post()
{
string profileId = Convert.ToString(x["id"]);
_logger.LogInformation("ProfileId" + profileId);

string sendId = Convert.ToString(x["changes"][0]["value"]["sender_id"]);
_logger.LogInformation("sendId" + sendId);

string sendername = Convert.ToString(x["changes"][0]["value"]["sender_name"]);
_logger.LogInformation("sendername" + sendername);

string postid = Convert.ToString(x["changes"][0]["value"]["post_id"]);
_logger.LogInformation("postid" + postid);

string message = Convert.ToString(x["changes"][0]["value"]["message"]);
_logger.LogInformation("message" + message);

string postTime = Convert.ToString(x["changes"][0]["value"]["created_time"]);
_logger.LogInformation("postTime" + postTime);

string share_id = Convert.ToString(x["changes"][0]["value"]["share_id"]);
_logger.LogInformation("share_id" + share_id);

string link = Convert.ToString(x["changes"][0]["value"]["link"]);
_logger.LogInformation("link" + link);





Domain.Socioboard.Models.Mongo.MongoFacebookFeed _FacebookPagePost = new MongoFacebookFeed();
_FacebookPagePost.Id = ObjectId.GenerateNewId();
_FacebookPagePost.ProfileId = profileId;
Expand All @@ -457,7 +555,7 @@ public async Task<HttpResponseMessage> Post()
try
{
_FacebookPagePost.FeedId = postid;
_logger.LogInformation("FeedId" + postid);
_logger.LogInformation("FeedId " + postid);
}
catch
{
Expand Down Expand Up @@ -562,12 +660,68 @@ public async Task<HttpResponseMessage> Post()
}
if (x["changes"][0]["value"]["item"] == "like" || x["changes"][0]["value"]["item"] == "like")
{

string profileId = Convert.ToString(x["id"]);
_logger.LogInformation("ProfileId" + profileId);
string sendId = Convert.ToString(x["changes"][0]["value"]["sender_id"]);
_logger.LogInformation("sendId" + sendId);
string sendername = Convert.ToString(x["changes"][0]["value"]["sender_name"]);
_logger.LogInformation("sendername" + sendername);
string postid = Convert.ToString(x["changes"][0]["value"]["post_id"]);
_logger.LogInformation("postid" + postid);
string postTime = Convert.ToString(x["changes"][0]["value"]["created_time"]);
_logger.LogInformation("postTime in like part" + postTime);
string like = null;
try
{
like = Convert.ToString(x["changes"][0]["value"]["likes"]);
_logger.LogInformation("like " + like);
}
catch (Exception ex)
{
_logger.LogInformation("like error"+ex);
}


if (!string.IsNullOrEmpty(profileId))
{
MongoFbPostComment fbPostComment = new MongoFbPostComment();
fbPostComment.Id = MongoDB.Bson.ObjectId.GenerateNewId();
fbPostComment.EntryDate = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss");

double datevalue = Convert.ToDouble(postTime);
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddSeconds(datevalue);
string printDate = dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
string createddate = Convert.ToDateTime(printDate).ToString("yyyy-MM-dd h:mm tt");
DateTime convertedDate = DateTime.SpecifyKind(DateTime.Parse(createddate), DateTimeKind.Utc);
fbPostComment.Commentdate = convertedDate.ToString();
_logger.LogInformation("commnet date" + fbPostComment.Commentdate);
//fbPostComment.Commentdate = DateTime.Parse(postTime).ToString("yyyy/MM/dd HH:mm:ss");
fbPostComment.PostId = postid;
fbPostComment.Likes = Convert.ToInt16(like);
fbPostComment.UserLikes = 0;
// fbPostComment.PictureUrl = message;
fbPostComment.FromName = sendername;
fbPostComment.FromId = sendId;
// fbPostComment.CommentId = comment_id;
// fbPostComment.Comment = message;
try
{

MongoRepository fbPostRepo = new MongoRepository("MongoFbPostComment", _appSettings);
fbPostRepo.Add<MongoFbPostComment>(fbPostComment);
_logger.LogInformation("added data in MongoFbPostComment");
}
catch (Exception ex)
{
_logger.LogInformation("comment error while adding in mongo");
_logger.LogInformation(ex.Message);
_logger.LogError(ex.StackTrace);
}
}


}

}
Expand Down
18 changes: 13 additions & 5 deletions src/Api.Socioboard/Helper/FacebookHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,23 @@ public static string UrlComposeMessage(Domain.Socioboard.Enum.FbProfileType prof
}
else
{
if (!string.IsNullOrEmpty(link))
{
args["link"] = link;
}
//if (!string.IsNullOrEmpty(link))
//{
// args["link"] = link;
//}
if (!string.IsNullOrEmpty(imagePath))
{
args["picture"] = imagePath.Replace("&amp;", "&");
}
ret = fb.Post("v2.7/" + fbUserId + "/feed", args).ToString();//v2.1
try
{
ret = fb.Post("v2.7/" + fbUserId + "/feed", args).ToString();//v2.1
}
catch(Exception ex)
{

}


}
ScheduledMessage scheduledMessage = new ScheduledMessage();
Expand Down
Loading

0 comments on commit 4eb9cf0

Please sign in to comment.