// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/domain/history/History.java
// public class History {
// 
//     private List<Call> calls;
// 
//     public History(Set<Member> conversationMember) {
//         List<Member> sortedMembers = new ArrayList<>(conversationMember);
//         sortedMembers.sort(Member::startedBefore);
//         calls = sortedMembers.stream().map(Member::toCall).collect(toList());
//     }
// 
//     public List<Call> getCalls() {
//         return calls;
//     }
// }
// 
// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/service/HistoryService.java
// @Service
// @Transactional
// public class HistoryService {
// 
//     @Autowired
//     private AuthUtils authUtils;
// 
//     @Autowired
//     private MemberRepository memberRepository;
// 
//     public History getHistoryFor(Principal principal) {
//         User user = authUtils.getAuthenticatedUser(principal);
// 
//         History history = user.prepareHistory();
// 
//         fillUserNamesBaseOnRtcIds(history);
// 
//         return history;
//     }
// 
//     private void fillUserNamesBaseOnRtcIds(History history) {
//         for (Call call : history.getCalls()) {
//             List<String> others = call.getOtherRtcIds().stream()
//                     .map(memberRepository::getByRtcId)
//                     .map(Member::getUsername)
//                     .collect(toList());
//             call.setOtherNames(others);
//         }
//     }
// 
// }


import org.nextrtc.examples.videochat_with_rest.domain.history.History;
import org.nextrtc.examples.videochat_with_rest.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
package org.nextrtc.examples.videochat_with_rest.controller;



@RestController
@RequestMapping("/action/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @RequestMapping(value = "get", method = RequestMethod.GET)
// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/domain/history/History.java
// public class History {
// 
//     private List<Call> calls;
// 
//     public History(Set<Member> conversationMember) {
//         List<Member> sortedMembers = new ArrayList<>(conversationMember);
//         sortedMembers.sort(Member::startedBefore);
//         calls = sortedMembers.stream().map(Member::toCall).collect(toList());
//     }
// 
//     public List<Call> getCalls() {
//         return calls;
//     }
// }
// 
// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/service/HistoryService.java
// @Service
// @Transactional
// public class HistoryService {
// 
//     @Autowired
//     private AuthUtils authUtils;
// 
//     @Autowired
//     private MemberRepository memberRepository;
// 
//     public History getHistoryFor(Principal principal) {
//         User user = authUtils.getAuthenticatedUser(principal);
// 
//         History history = user.prepareHistory();
// 
//         fillUserNamesBaseOnRtcIds(history);
// 
//         return history;
//     }
// 
//     private void fillUserNamesBaseOnRtcIds(History history) {
//         for (Call call : history.getCalls()) {
//             List<String> others = call.getOtherRtcIds().stream()
//                     .map(memberRepository::getByRtcId)
//                     .map(Member::getUsername)
//                     .collect(toList());
//             call.setOtherNames(others);
//         }
//     }
// 
// }


// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/controller/HistoryController.java
import org.nextrtc.examples.videochat_with_rest.domain.history.History;
import org.nextrtc.examples.videochat_with_rest.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;

package org.nextrtc.examples.videochat_with_rest.controller;



@RestController
@RequestMapping("/action/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @RequestMapping(value = "get", method = RequestMethod.GET)
    public History getHistory(Principal authentication) {