Exemple #1
0
	def get_subscriptions(self):
		userid = login.get_user_fullid(self.key)
		userdata = self.get(userid)
		if userdata is None:
			return None


		objr = []
		rooms = core.rooms.Rooms(self.key)
		
		if "subscriptions" in userdata:
			subids = userdata["subscriptions"]
			for subid in subids:
				if "id" in subid:
					o = rooms.get_info(subid["id"])
					rooms.format_room(o)
					rooms.strip_secure_details(o)
					objr.append(o)


			return objr

		else:
			return None
Exemple #2
0
	def handle_rooms(self, url):
	
		obj = None
		rooms = core.rooms.Rooms(self.key)

		if url == "create":

			lat = 0.0
			lng = 0.0
			rsize = 5

			try:
				rsize = int(self.get_argument("size"))
				lat = float(self.get_argument("lat"))
				lng = float(self.get_argument("long"))
			except:
				return obj

			room   =  {"name"		 : str(self.get_argument("name")),
					   "dsc" 		 : str(self.get_argument("dsc")),
					   "address" 	 : str(self.get_argument("address")),
					   "status" 	 : "",
					   "size"        : rsize,
					   "type"        : rooms.room_type_place,
					   "security"    : {"type": rooms.security_level_open, "password": ""},
					   "locname"	 : "",
					   "loc" 		 : [lat, lng],
					   "event" 		 : {"start": 0, "end": 0},
					   "ratings" 	 : {"rating1" : 0, "rating2" : 0},
					   "tickets"	 : {"message" : "", "url": "", "price": ""},
					   "conversation": None}


			oid = rooms.create(room)
			obj = {"result" : "success", "objid" : str(oid)}

			if obj is not None:
				rooms.strip_secure_details(obj)
				
		elif url == "get":
			cuid = login.get_user_fullid(self.key)
			oc = rooms.get(self.get_argument("lat", "0"), self.get_argument("long", "0"), self.get_argument("rad", "100"), None, None)
			
			if oc is None:
				obj = {"result" : "error", "message" : "No rooms around."}
				return 0
			
			obj = []
			for o in oc:
				rooms.strip_secure_details(o)
				rooms.format_room(o)
				o["subscribed"] = rooms.is_subscribed(o, cuid)
				o["intheroom"] = rooms.is_intheroom(o, cuid)
				

				obj.append(o)


		elif url == "get_info":
			cuid = login.get_user_fullid(self.key)

			o = rooms.get_info(self.get_argument("id", "0"))
			
			if o is None:
				obj = {"result" : "error", "message" : "No rooms around."}
				return obj
			
			rooms.strip_secure_details(o)
			rooms.format_room(o)
			o["subscribed"] = rooms.is_subscribed(o, cuid)
			o["intheroom"] = rooms.is_intheroom(o, cuid)
			obj = o


		elif url == "enter":
			id = self.get_argument("id", "0")
			
			if id == "0":
				return 0

			oc = rooms.enter(id)
			if oc == 1:
				obj = {"result" : "success"}


		elif url == "leave":
			id = self.get_argument("id", "0")
			
			if id == "0":
				return 0

			oc = rooms.leave(id)
			if oc == 1:
				obj = {"result" : "success"}


		elif url == "subscribe":
			id = self.get_argument("id", "0")
			
			if id == "0":
				return 0

			oc = rooms.subscribe(id)
			if oc == 1:
				obj = {"result" : "success"}


		elif url == "unsubscribe":
			id = self.get_argument("id", "0")
			
			if id == "0":
				return 0

			oc = rooms.unsubscribe(id)
			if oc == 1:
				obj = {"result" : "success"}

		elif url == "get_conversation":
			id    = str(self.get_argument("id", "0"))
			pid   = str(self.get_argument("pid", "0"))
			skip  = str(self.get_argument("skip", "0"))
			count = str(self.get_argument("count", "7"))
			noteskip  = str(self.get_argument("noteskip", "0"))
			notecount = str(self.get_argument("notecount", "5"))
			
			obj = {"result" : "error"}
			
			if id == "0":
				return obj

			try:
				skip = int(skip)
			except:
				skip = 0

			try:
				count = int(count)
			except:
				count = 1

			try:
				noteskip = int(noteskip)
			except:
				noteskip = 0

			try:
				notecount = int(notecount)
			except:
				notecount = 5

			oc = rooms.get_conversation(id)
			if oc is not None:
				conversations = core.conversations.Conversations(self.key)
				obj = conversations.get(conversations.get_default, oc, pid, skip, count, noteskip, notecount)


		return obj