コード例 #1
0
 /**
  * Insert inner comment in DB
  * @param  integer $id
  * @param  Request $request
  * @param  integer $messageId
  * @param  object $reply
  * @return void
  */
 private function insertInnerComment($id, $request, $messageId, $reply)
 {
     $innerComment = new InnerComment();
     if ($this->reaction->where('fb_post_id', $messageId)->exists()) {
         $innerComment->reaction_id = $this->reaction->where('fb_post_id', $messageId)->first()->id;
     }
     $innerComment->user_id = Auth::user()->id;
     $innerComment->fb_post_id = $reply->id;
     $innerComment->fb_reply_id = $messageId;
     $innerComment->message = $request->input('answer');
     $innerComment->post_date = Carbon::now();
     $innerComment->save();
 }
コード例 #2
0
 /**
  * Fetch inner comments of facebook
  * @param  datetime $newest
  * @return void
  */
 private function fetchInnerComments($newest)
 {
     $messages = $this->getComments();
     foreach ($messages as $key => $message) {
         $comments = $this->facebookContent->fetchInnerComments($newest, $message['fb_post_id']);
         if ($comments == null) {
             continue;
         }
         foreach ($comments->data as $key => $comment) {
             if ($comment->from->id != config('crm-launcher.facebook_credentials.facebook_page_id') && new Datetime(changeFbDateFormat($comment->created_time)) > new Datetime($newest)) {
                 if (!$this->contact->findByFbId($comment->from->id)->exists()) {
                     $contact = $this->contact->createContact('facebook', $comment);
                 } else {
                     $contact = $this->contact->where('facebook_id', $comment->from->id)->first();
                 }
                 $innerComment = new InnerComment();
                 $innerComment->fb_reply_id = $message['fb_post_id'];
                 $innerComment->post_date = changeFbDateFormat($comment->created_time);
                 $innerComment->contact_id = $contact->id;
                 if (is_a($message, "Rubenwouters\\CrmLauncher\\Models\\Answer")) {
                     $innerComment->answer_id = $message['id'];
                 } else {
                     if (is_a($message, "Rubenwouters\\CrmLauncher\\Models\\Reaction")) {
                         $innerComment->reaction_id = $message['id'];
                     } else {
                         $innerComment->message_id = $message['id'];
                     }
                 }
                 $innerComment->fb_post_id = $comment->id;
                 $innerComment->message = $comment->message;
                 $innerComment->save();
                 $this->media->handleMedia($innerComment->id, $comment, 'facebook_innerComment');
             }
         }
     }
 }