Example #1
0
	users.forEach(function(user) {

		try {
			return Meteor.call('addUserToRoom', {
				rid: item.rid,
				username: user.username,
			});
		} catch ({ error }) {
			if (error === 'cant-invite-for-direct-room') {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language),
				});
			} else {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__(error, null, currentUser.language),
				});
			}
		}
	});
Example #2
0
			showAlert = () => {
				this.openAlert({
					title: TAPi18n.__('Enter_your_E2E_password'),
					html: TAPi18n.__('Click_here_to_enter_your_encryption_password'),
					modifiers: ['large'],
					closable: false,
					icon: 'key',
					action() {
						showModal();
					},
				});
			};
				alerts.forEach((alert) => {
					if (Users.bannerExistsById(adminUser._id, `alert-${ alert.id }`)) {
						return;
					}

					const msg = {
						msg: `*${ TAPi18n.__('Rocket_Chat_Alert', adminUser.language) }:*\n\n*${ TAPi18n.__(alert.title, adminUser.language) }*\n${ TAPi18n.__(alert.text, ...(alert.textArguments || []), adminUser.language) }\n${ alert.infoUrl }`,
						rid: [adminUser._id, 'rocket.cat'].sort().join(''),
					};

					Meteor.runAsUser('rocket.cat', () => Meteor.call('sendMessage', msg));
				});
Example #4
0
export function parseMessageTextPerUser(messageText, message, receiver) {
	if (!message.msg && message.attachments && message.attachments[0]) {
		const lng = receiver.language || settings.get('Language') || 'en';

		return message.attachments[0].image_type ? TAPi18n.__('User_uploaded_image', { lng }) : TAPi18n.__('User_uploaded_file', { lng });
	}

	if (message.msg && message.t === 'e2e') {
		const lng = receiver.language || settings.get('Language') || 'en';

		return TAPi18n.__('Encrypted_message', { lng });
	}

	return messageText;
}
Example #5
0
export const displayDefault = (msg = null, i18n = false) => {
    if (msg) {
        msg = i18n == true ? TAPi18n.__(msg) : msg;
    } else {
        msg = TAPi18n.__('alert.question');
    }

    // sAlert.error(msg);
    Bert.alert({
        title: 'Default',
        message: msg,
        type: 'default',
        style: 'growl-top-right'
    });
};
Example #6
0
        method : function(error, result) {
          if (!error) {
            var self = this;
            let selfresult=result.data.id["$id"];
            let scopeId=Session.get('scopeId');
            let scope=Session.get('scope');

            let options = {
              width: 500,
              height: 500,
              quality: 75
            };

            IonPopup.confirm({title:TAPi18n.__('Photo'),template:TAPi18n.__('Voulez vous prendre une photo ?'),
            onOk: function(){

              MeteorCameraUI.getPicture(options,function (error, data) {
                // we have a picture
                if (! error) {

                  let str = +new Date + Math.floor((Math.random() * 100) + 1) + ".jpg";

                  Meteor.call("cfsbase64tos3up",data,str,scope,scopeId, function (error, photoret) {
                    if(photoret){
                      Meteor.call('photoNewsUpdate',selfresult,photoret, function (error, retour) {
                        if(retour){
                          newsListSubs.reset();
                        }
                      });
                    }else{
                      //console.log('error',error);
                    }

                  });

                }});

              },
              onCancel: function(){

              }
            });

            Meteor.call('pushNewNewsAttendees',scopeId,selfresult);
            Router.go('newsList', {_id: Session.get('scopeId'),scope:Session.get('scope')});

          }
        },
Example #7
0
	blockUnsafeImages(message) {
		if (this.enabled && this.serviceAccount && message && message.file && message.file._id) {
			const file = RocketChat.models.Uploads.findOne({ _id: message.file._id });
			if (file && file.type && file.type.indexOf('image') !== -1 && file.store === 'GoogleCloudStorage:Uploads' && file.GoogleStorage) {
				if (this.incCallCount(1)) {
					const bucket = this.storageClient.bucket(RocketChat.settings.get('FileUpload_GoogleStorage_Bucket'));
					const bucketFile = bucket.file(file.GoogleStorage.path);
					const results = Meteor.wrapAsync(this.visionClient.detectSafeSearch, this.visionClient)(bucketFile);
					if (results && results.adult === true) {
						FileUpload.getStore('Uploads').deleteById(file._id);
						const user = RocketChat.models.Users.findOneById(message.u && message.u._id);
						if (user) {
							RocketChat.Notifications.notifyUser(user._id, 'message', {
								_id: Random.id(),
								rid: message.rid,
								ts: new Date,
								msg: TAPi18n.__('Adult_images_are_not_allowed', {}, user.language),
							});
						}
						throw new Meteor.Error('GoogleVisionError: Image blocked');
					}
				} else {
					console.error('Google Vision: Usage limit exceeded');
				}
				return message;
			}
		}
	}
Example #8
0
export const displayError = (error) =>  {
  if (error) {
    // It would be better to not alert the error here but inform the user in some
    // more subtle way
    alert(TAPi18n.__(error.error));
  }
};
Example #9
0
					Meteor.call('unarchiveRoom', rid, function(err) {
						if (err) {
							return handleError(err);
						}
						toastr.success(TAPi18n.__('Room_unarchived'));
						callbacks.run('unarchiveRoom', AdminChatRoom.findOne(rid));
					});
Example #10
0
					Meteor.call('saveRoomSettings', rid, 'roomAnnouncement', this.$('input[name=roomAnnouncement]').val(), function(err) {
						if (err) {
							return handleError(err);
						}
						toastr.success(TAPi18n.__('Room_announcement_changed_successfully'));
						callbacks.run('roomAnnouncementChanged', AdminChatRoom.findOne(rid));
					});
Example #11
0
function excuteEditForm(doc) {
    swal({
        title: "Pleas Wait",
        text: "Getting RingPullTransfers....", showConfirmButton: false
    });
    alertify.ringPullTransfer(fa('pencil', TAPi18n.__('pos.ringPullTransfer.title')), renderTemplate(editTmpl, doc)).maximize();
}
Example #12
0
export const displayError = (error) => {console.log(error);
  if (error) {
    // It would be better to not alert the error here but inform the user in some
    // more subtle way
    alert(TAPi18n.__(error.error)); // eslint-disable-line no-alert
  }
};
Example #13
0
Meteor.startup(function() {
	RocketChat.MessageTypes.registerType({
		id: 'jitsi_call_started',
		system: true,
		message: TAPi18n.__('Started_a_video_call'),
	});
});
Example #14
0
    'click .js-destroy-item': function (event, instance) {
        event.preventDefault();
        let itemDoc = this;
        if (AutoForm.getFormId() == "Pos_convertItemUpdate") { //check if update form
            swal({
                    title: "Are you sure?",
                    text: "លុបទំនិញមួយនេះ?",
                    type: "warning", showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes, delete it!",
                    closeOnConfirm: false
                },
                function () {
                    if (!deletedItem.findOne({fromItemId: itemDoc.fromItemId})) {
                        deletedItem.insert(itemDoc);
                    }
                    itemsCollection.remove({fromItemId: itemDoc.fromItemId});
                    swal.close();
                });
        } else {
            destroyAction(
                itemsCollection, {
                    _id: this._id
                }, {
                    title: TAPi18n.__('pos.convertItem.schema.fromItemId.label'),
                    itemTitle: this.fromItemId
                }
            );
        }

    },
Example #15
0
					action:prevent(getUser, ({ username }) => {
						const rid = Session.get('openedRoom');
						if (!hasAllPermission('mute-user', rid)) {
							return toastr.error(TAPi18n.__('error-not-allowed'));
						}
						Meteor.call('unmuteUserInRoom', { rid, username }, success(() => toastr.success(TAPi18n.__('User_unmuted_in_room'))));
					}),
Example #16
0
	getCountdown: function () {
		if (this.data && this.data["data-questionIndex"]) {
			return false;
		}
		let countdownValue = (Session.get("countdownInitialized") && lib.countdown) ? lib.countdown.get() : 0;
		return TAPi18n.__("view.voting.seconds_left", {value: countdownValue, count: countdownValue});
	}
Example #17
0
				action: prevent(getUser, ({ username }) => {
					const rid = Session.get('openedRoom');
					const room = ChatRoom.findOne(rid);
					if (!hasAllPermission('mute-user', rid)) {
						return toastr.error(TAPi18n.__('error-not-allowed'));
					}
					modal.open({
						title: t('Are_you_sure'),
						text: t('The_user_wont_be_able_to_type_in_s', room.name),
						type: 'warning',
						showCancelButton: true,
						confirmButtonColor: '#DD6B55',
						confirmButtonText: t('Yes_mute_user'),
						cancelButtonText: t('Cancel'),
						closeOnConfirm: false,
						html: false,
					}, () =>
						Meteor.call('muteUserInRoom', { rid, username }, success(() => {
							modal.open({
								title: t('Muted'),
								text: t('User_has_been_muted_in_s', room.name),
								type: 'success',
								timer: 2000,
								showConfirmButton: false,
							});
						}))
					);
				}),
Example #18
0
			Meteor.call('insertOrUpdateSound', soundData, (error, result) => {
				if (result) {
					soundData._id = result;
					soundData.random = Math.round(Math.random() * 1000);

					if (this.soundFile) {
						toastr.info(TAPi18n.__('Uploading_file'));

						const reader = new FileReader();
						reader.readAsBinaryString(this.soundFile);
						reader.onloadend = () => {
							Meteor.call('uploadCustomSound', reader.result, this.soundFile.type, soundData, (uploadError/* , data*/) => {
								if (uploadError != null) {
									handleError(uploadError);
									console.log(uploadError);
									return;
								}
							}
							);
							delete this.soundFile;
							toastr.success(TAPi18n.__('File_uploaded'));
						};
					}

					toastr.success(t('Custom_Sound_Saved_Successfully'));

					this.cancel(form, soundData.name);
				}

				if (error) {
					handleError(error);
				}
			});
Example #19
0
			action: prevent(getUser, (user) => {
				const rid = Session.get('openedRoom');
				const room = ChatRoom.findOne(rid);
				if (!hasAllPermission('remove-user', rid)) {
					return toastr.error(TAPi18n.__('error-not-allowed'));
				}
				modal.open({
					title: t('Are_you_sure'),
					text: t('The_user_will_be_removed_from_s', roomTypes.getRoomName(room.t, room)),
					type: 'warning',
					showCancelButton: true,
					confirmButtonColor: '#DD6B55',
					confirmButtonText: t('Yes_remove_user'),
					cancelButtonText: t('Cancel'),
					closeOnConfirm: false,
					html: false,
				}, () => Meteor.call('removeUserFromRoom', { rid, username: user.username }, success(() => {
					modal.open({
						title: t('Removed'),
						text: t('User_has_been_removed_from_s', roomTypes.getRoomName(room.t, room)),
						type: 'success',
						timer: 2000,
						showConfirmButton: false,
					});
					return this.instance.clear();
				})));
			}),
Example #20
0
						Meteor.call('saveRoomSettings', rid, 'roomType', val, function(err) {
							if (err) {
								return handleError(err);
							} else {
								toastr.success(TAPi18n.__('Room_type_changed_successfully'));
							}
						});
Example #21
0
	constructor() {
		this._online = new ReactiveVar(null);

		this._customColor = new ReactiveVar();
		this._onlineColor = new ReactiveVar('#C1272D');
		this._offlineColor = new ReactiveVar('#666666');

		this._customFontColor = new ReactiveVar();
		this._onlineFontColor = new ReactiveVar('#FFFFFF');
		this._offlineFontColor = new ReactiveVar('#FFFFFF');

		this._title = new ReactiveVar('Rocket.Chat');
		this._registrationForm = new ReactiveVar(true);
		this._showSwitchDepartmentForm = new ReactiveVar(false);
		this._allowSwitchingDepartments = new ReactiveVar(false);
		this._offlineMessage = new ReactiveVar('');
		this._offlineUnavailableMessage = new ReactiveVar('');
		this._displayOfflineForm = new ReactiveVar(true);
		this._offlineSuccessMessage = new ReactiveVar(TAPi18n.__('Thanks_We_ll_get_back_to_you_soon'));
		this._videoCall = new ReactiveVar(false);
		this._fileUpload = new ReactiveVar(false);
		this._transcriptMessage = new ReactiveVar('');
		this._conversationFinishedMessage = new ReactiveVar('');
		this._nameFieldRegistrationForm = new ReactiveVar(false);
		this._emailFieldRegistrationForm = new ReactiveVar(false);
		this._connecting = new ReactiveVar(false);
		this._room = new ReactiveVar(null);
		this._department = new ReactiveVar(null);
		this._widgetOpened = new ReactiveVar(false);
		this._ready = new ReactiveVar(false);
		this._agent = new ReactiveVar();

		this.stream = new Meteor.Streamer('livechat-room');

		this._guestName = new ReactiveVar();
		this._guestEmail = new ReactiveVar();

		Tracker.autorun(() => {
			if (this._room.get() && visitor.getId()) {
				RoomHistoryManager.getMoreIfIsEmpty(this._room.get());
				visitor.subscribeToRoom(this._room.get());
				visitor.setRoom(this._room.get());

				Meteor.call('livechat:getAgentData', { roomId: this._room.get(), token: visitor.getToken() }, (error, result) => {
					if (!error) {
						this._agent.set(result);
					}
				});
				this.stream.on(this._room.get(), { token: visitor.getToken() }, (eventData) => {
					if (!eventData || !eventData.type) {
						return;
					}

					if (eventData.type === 'agentData') {
						this._agent.set(eventData.data);
					}
				});
			}
		});
	}
Example #22
0
		onlineAgents.forEach((agent) => {
			const { _id, active, emails, language, status, statusConnection, username } = agent;

			sendNotification({
				// fake a subscription in order to make use of the function defined above
				subscription: {
					rid: room._id,
					t : room.t,
					u: {
						_id,
					},
					receiver: [{
						active,
						emails,
						language,
						status,
						statusConnection,
						username,
					}],
				},
				sender: room.v,
				hasMentionToAll: true, // consider all agents to be in the room
				hasMentionToHere: false,
				message: Object.assign(message, { u: room.v }),
				notificationMessage: message.msg,
				room: Object.assign(room, { name: TAPi18n.__('New_livechat_in_queue') }),
				mentionIds: [],
			});
		});
Example #23
0
Template.signin.onRendered(function () {
  pageSession.set( 'error', false );
  pageSession.set( 'cities', null );
  pageSession.set('codepostal', null );
  pageSession.set('cityselect', null );

  let geolocate = Session.get('geolocate');
  if(geolocate){
    var onOk=IonPopup.confirm({template:TAPi18n.__('Utiliser votre position actuelle ?'),
    onOk: function(){
      let geo = Location.getReactivePosition();
      if(geo && geo.latitude){
        let latlng = {latitude: parseFloat(geo.latitude), longitude: parseFloat(geo.longitude)};
        Meteor.call('getcitiesbylatlng',latlng,function(error, result){
          if(result){
            pageSession.set('codepostal', result.postalCodes[0].postalCode);
            pageSession.set('cityselect', result.insee);
            Meteor.call('getcitiesbypostalcode',result.postalCodes[0].postalCode,function(error, data){
              if(data){
              pageSession.set( 'cities', data);
              }
            })
        }
        });
      }
    }});
  }
});
Example #24
0
 'click .js-destroy-item': function (event, instance) {
     destroyAction(
         itemsCollection,
         {_id: this._id},
         {title: TAPi18n.__('simplePos.order.schema.itemId.label'), itemTitle: this.itemId}
     );
 }
Example #25
0
export const destroyAction = (collection, selector = {}, options = {}) => {
    check(collection, Mongo.Collection);
    check(selector, Object);
    check(options, Object);

    _.defaults(options, {
        title: 'Delete',
        itemTitle: 'this item',
        successMsg: null,
        errorMsg: null,
        i18n: true
    });

    alertify.confirm(
        fa("trash", options.title),
        TAPi18n.__('alert.deleteConfirm', {itemTitle: options.itemTitle}),
        function () {
            collection.remove(selector, function (error) {
                if (error) {
                    // sAlert.error(options.errorMsg ? options.errorMsg : error.message);
                    displayError(options.errorMsg, options.i18n);
                } else {
                    // sAlert.success(options.successMsg);
                    displaySuccess(options.successMsg, options.i18n);
                }
            });
        },
        null
    );
};
Example #26
0
  ProjectLogo.resumable.on('fileAdded', (file) => {
    // Available extensions for pictures
    const acceptedExtensions = ['jpg', 'jpeg', 'png', 'gif'];

    // Make sure the file extension is allowed
    if (fileNameEndsWith(file.file.name, acceptedExtensions)) {
      // Insert record about file to collection
      ProjectLogo.insert({
        _id: file.uniqueIdentifier,
        filename: file.fileName,
        contentType: file.file.type,
      }, (error) => {
        if (error) {
          // Handle error condition
          throw new Meteor.Error('File creation failed!', error);
        }

        // Start uploading
        Session.set('logoUploading', true);

        // Upload file
        ProjectLogo.resumable.upload();
      });
    } else {
      // Finish uploading
      Session.set('logoUploading', false);

      // Get extension error message
      const message = TAPi18n.__('uploadProjectLogo_acceptedExtensions');

      // Alert user of extension error
      sAlert.error(message, { timeout: 'none' });
    }
  });
Example #27
0
function excuteEditForm(doc) {
    swal({
        title: "Pleas Wait",
        text: "Getting CompanyExchangeRingPulls....", showConfirmButton: false
    });
    alertify.companyExchangeRingPull(fa('pencil', TAPi18n.__('pos.companyExchangeRingPull.title')), renderTemplate(editTmpl, doc)).maximize();
}
Example #28
0
				action: () => {
					modal.open({
						title: TAPi18n.__('Save_your_encryption_password'),
						html: true,
						text: `<div>${ passwordRevealText }</div>`,
						showConfirmButton: true,
						showCancelButton: true,
						confirmButtonText: TAPi18n.__('I_saved_my_password_close_this_message'),
						cancelButtonText: TAPi18n.__('I_ll_do_it_later'),
					}, (confirm) => {
						if (!confirm) {
							return;
						}
						localStorage.removeItem('e2e.randomPassword');
						this.closeAlert();
					});
				},
Example #29
0
		RocketChat.models.Roles.findUsersInRole('admin').forEach((adminUser) => {
			const msg = {
				msg: `*${ TAPi18n.__('Update_your_RocketChat', adminUser.language) }*\n${ TAPi18n.__('New_version_available_(s)', update.lastestVersion.version, adminUser.language) }\n${ update.lastestVersion.infoUrl }`,
				rid: [adminUser._id, 'rocket.cat'].sort().join(''),
			};

			Meteor.runAsUser('rocket.cat', () => Meteor.call('sendMessage', msg));

			RocketChat.models.Users.addBannerById(adminUser._id, {
				id: 'versionUpdate',
				priority: 10,
				title: 'Update_your_RocketChat',
				text: 'New_version_available_(s)',
				textArguments: [update.lastestVersion.version],
				link: update.lastestVersion.infoUrl,
			});
		});
Example #30
0
	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');