protected override void CheckIfRefExists(out ActivityAction refActivity, out object activityRecord) { refActivity = ActivityActions.GetRefActivity("like_activity_action", activity.ActivityId, "activity_action", userId, false); activityRecord = Likes.GetByResourceAndPoster((uint)activity.ActivityId, "activity_action", userId, "user"); if (refActivity != null && !IsActivityUpdate(refActivity)) { throw new Exception($"Like to {activity.ActivityId} by user {userId} already exists in activity actions"); } if (activityRecord != null && !IsRecordUpdate(activityRecord)) { throw new Exception($"Like to {activity.ActivityId} by user {userId} already exists in Likes table"); } }
protected override void CheckIfRefNotExists(out ActivityAction refActivityAction, out object actionRecord) { refActivityAction = ActivityActions.GetRefActivity("like_activity_action", activity.ActivityId, "activity_action", userId, true); actionRecord = Likes.GetByResourceAndPoster((uint)activity.ActivityId, "activity_action", userId, "user"); if ((actionRecord == null && refActivityAction != null) || (actionRecord != null && refActivityAction == null)) { Logger.Instance.Warn($"Inconsistancy in likes and activity tables, to {activity.ActivityId} by user {userId}"); } if (refActivityAction == null) { Logger.Instance.Warn($"like to {activity.ActivityId} by user {userId} not exists in activity actions"); } if (actionRecord == null) { Logger.Instance.Warn($"like to {activity.ActivityId} by user {userId} not exists in likes table"); } }
protected override void CheckIfRefNotExists(out ActivityAction refActivityAction, out object actionRecord) { Logger.Instance.Debug($"Comment id = {reqParams.comment_id}"); var comment = Comments.GetByCommentId(reqParams.comment_id); actionRecord = comment ?? throw new Exception($"Comment to {activity.ActivityId} by user {userId} not exists in Comments table"); var allComments = ActivityActions.GetByObjectId((uint)activity.ActivityId, "activity_actions"); foreach (var aa in allComments) { Logger.Instance.Debug($"found {aa.type} , id {aa.action_id} on time {aa.modified_date}"); } Logger.Instance.Debug($"looking to match comment on {activity.ActivityId} with date {comment.creation_date}"); refActivityAction = ActivityActions.GetRefActivity("comment_activity_action", activity.ActivityId, "activity_action", userId, false, comment.creation_date); if (refActivityAction == null) { Logger.Instance.Warn($"Inconsistancy in Comments and activity tables , to {activity.ActivityId} by user {userId}"); //throw new Exception($"Inconsistancy in Comments and activity tables , to {activity.ActivityId} by user {userId}"); } }