示例#1
0
const getRoomName = function() {
	const room = ChatRoom.findOne(Session.get('openedRoom'));
	if (!room) {
		return;
	}
	if (room.name) {
		return `#${ room.name }`;
	}

	return t('conversation_with_s', RocketChat.roomTypes.getRoomName(room.t, room));
};
示例#2
0
Meteor.startup(() => {
	RocketChat.roomTypes.setRoomFind('l', (_id) => RocketChat.models.Rooms.findLivechatById(_id).fetch());

	RocketChat.authz.addRoomAccessValidator(function(room, user) {
		return room && room.t === 'l' && user && RocketChat.authz.hasPermission(user._id, 'view-livechat-rooms');
	});

	RocketChat.authz.addRoomAccessValidator(function(room, user, extraData) {
		if (!room && extraData && extraData.rid) {
			room = RocketChat.models.Rooms.findOneById(extraData.rid);
		}
		return room && room.t === 'l' && extraData && extraData.visitorToken && room.v && room.v.token === extraData.visitorToken;
	});

	RocketChat.callbacks.add('beforeLeaveRoom', function(user, room) {
		if (room.t !== 'l') {
			return user;
		}
		throw new Meteor.Error(TAPi18n.__('You_cant_leave_a_livechat_room_Please_use_the_close_button', {
			lng: user.language || RocketChat.settings.get('Language') || 'en',
		}));
	}, RocketChat.callbacks.priority.LOW, 'cant-leave-room');
});
示例#3
0
		if (result) {
			return {
				currentPage: 1 + result.message.start / pageSize,
				numOfPages: Math.ceil(result.message.numFound / pageSize),
			};
		}
	},
});

Template.ChatpalSearchSingleMessage.helpers({
	roomIcon() {
		const room = Session.get(`roomData${ this.rid }`);
		if (room && room.t === 'd') {
			return 'at';
		}
		return RocketChat.roomTypes.getIcon(room && room.t);
	},

	roomLink() {
		const subscription = RocketChat.models.Subscriptions.findOne({ rid: this.rid });
		return RocketChat.roomTypes.getRouteLink(subscription.t, subscription);
	},

	roomName() {
		const room = Session.get(`roomData${ this.rid }`);
		return RocketChat.roomTypes.getRoomName(room.t, room);
	},

	time() {
		return DateFormat.formatTime(this.created);
	},