Esempio n. 1
0
 /**
  * Checks the status of a friendship
  *
  * @param id the user to check friendship status with
  * @return a string representing the status
  */
 public String checkFriendship(Long id) {
   User current = Application.user();
   if (Application.user().id == id) {
     return "";
   }
   Relationship r1 =
       Relationship.find(
               "SELECT r FROM Relationship r where r.from = ?1 AND r.to = ?2", current, this)
           .first();
   Relationship r2 =
       Relationship.find(
               "SELECT r FROM Relationship r where r.to = ?1 AND r.from = ?2", current, this)
           .first();
   if (r1 != null) {
     if (r1.accepted) {
       return "Friends";
     }
     if (r1.requested) {
       return "Friendship Requested";
     }
   }
   return "Request Friendship";
 }
Esempio n. 2
0
 /**
  * Get a list of any users who have requested to be friends
  *
  * @return a list of relationships related to incoming friend requests
  */
 public List<Relationship> requestedFriends() {
   return Relationship.find(
           "SELECT r FROM Relationship r where r.to = ? and r.requested = true and r.accepted = false",
           this)
       .fetch();
 }
Esempio n. 3
0
 /**
  * Get any confirmed friends
  *
  * @return a list of relationships for confirmed friends
  */
 public List<Relationship> confirmedFriends() {
   return Relationship.find(
           "SELECT r FROM Relationship r where r.from = ? and r.accepted = true", this)
       .fetch();
 }