Forum Documentation Showcase Pricing Learn more

Privacy with Messaging: How to attach FileUploader to Message and secure it?

Hi @emmanuel,

I’d like to secure my User’s Messages, including their attachments (pdf,docx, jpg anything). I’d like to use Privacy Rules to ensure that only the Creator of the message and its Recipient (1-to-1 messaging) can see the message and its attachments, and that no one can use a URL to see the attachment.

Message Type Data Structure:

  • “From”; type = User, list=no
  • “To”; type = User, list = no
  • "Body; type = text, list = no
  • “Attach 1”; type = file, list = no
  • “Attach 2”; type = file, list = no
  • "Creator’ = Built in

Privacy:
Type: Message

  • When Current User is This Message’s Creator or Current User is This Message’s To (this is saying only when the message’s creator is the current user or the Current User is the message’s “To”/recipient)

  • Users who match this rule can: View all fields, Find in Searches, View Attached Files. Other users: No permissions.

  • Now I realise that this privacy is attached to the message, which is what I want. But it generates the below bug.

Design of Chat

  • Create Repeating Group, Type of Content = “Message”

  • Data Source: Search for Messages (Constraints > “Created by” = Current User and “To” = Get company (User) from URL) merged with Search for Messages (Constraints > “Created by” = Get company (User) from URL and “To” = Current User):sorted by Created Date. This works as messages are only shown when these conditions are met

  • Create textbox within repeating group. Dynamic Data>Current Cell’s Message’s Body

  • Create links (using icons) for download of attachments: Current Cell’s Message’s Attach 1’s URL

  • Create message composer group, Type of Content = Message

  • Include Multiline input for message text

  • Include FileUploaders for Attach1 and Attach2. Make this file private = yes. Attach file to = Parent’s group’s message (the text is blue and no errors are shown).

  • Create ‘Send’ button to send the message

  • Workflow for Send: Create> New message. Body = Multiline input; Attach 1 = FileUploader1; Attach 2 = FileUploader2; To = Get company (User) from URL; From = Current User> Reset Relevant Inputs

What happens:

  • Start chat from either side > Works well with text

  • Upload doc1> Windows Explorer opens, I can select a file, but then double clicking any file or selecting a file in Chrome on mobile or desktop = BUG! > "Sorry, we ran into a temporary bug and can’t complete your request. We’ll fix it as soon as we can; please try again in a bit!"

Any help with this would be greatly appreciated!

1 Like

So when I test i don’t see the error message. Can you still see it?

Hi Emmanuel,

I’ve tested again and the bug alert still shows up when I try upload a file on both my phone and laptop (You can see this in the screenshot). On the FileUploader I’ve used: Attach file to> Parent’s Group’s Message (text is blue and no errors found). When I try upload, the bug alert shows: “Sorry, we ran into a temporary bug and can’t complete your request. We’ll fix it as soon as we can; please try again in a bit!”

As a test, I tried using a PictureUploader (Message> type= image, list=“no”). On the options for the PicUploader I used (Attach file to>Parent’s Group’s Message). The PicUploader then works, it doesn’t show a bug when selecting a picture.

However, my privacy rules also don’t appear to be working for the image; if I paste the URL into another window (and become a non-logged in User, and also a User who didn’t create the message) I can see the image.

Really can’t understand where I’m going wrong?

We need to fix the error message first. Which URL are you on when you see it? When i test I don’t see it.

Hi Emmanuel,

When you say “We need to fix the error message first” - do you mean the bug alert “Sorry, we ran into a temporary bug and can’t complete your request. We’ll fix it as soon as we can; please try again in a bit!”? If so, it was the “version-test” URL of the chat page I was using.

I made a new basic app, where I only created 2 demo users and 1 extra data type called “Message”, and the bug was there. My Message Type had fields of:

  • To > User, No list
  • From > User, No list
  • Body > Text, no list
  • Attach1 > File, no list

I made a basic messaging form with a Dropdown for “To” (who will receive the message), Dropdown for “From” (who sent the message), a Multiline Input for the message body, a FileUploader (which I grouped by itself and set its “Type of Content = Message”; Make file Private = Yes; Attach file to = Parent Group’s Message), and a “Send” button.

Send Button’s Workflow = (Create New Message > From = Dropdown From’s Value; To = Dropdown To’s Value; Body = Multiline Input’s value; Attach = FileUploader’s Value) and the problem was replicated - when I test it in Development (version-test), when I click on the Uploader, the Windows Select File window opens, I can find a file I’d like to attach, but when I double click on it/or click and press the ‘Open’ button, the same alert shows (as attached).

.

We fixed the message so you can understand what is going on.

Hi Emmanuel,

Great, thanks for that! I’ve tried uploading and after selecting a file saw the “This is a private file, so please select an object to attach it to” alert. So progress :slight_smile: But it still woudn’t attach the file.

In the Editor, I thought I had selected an Object “Parent’s Group’s Message” - the syntax was blue in the editor and no issues were found? Wouldn’t “Message” be the object I want to attach it to? I also tried “Parent Group’s Message’s Creator” - the syntax is blue, no issues, but I still get the “This is a private file, so please select an object to attach it to” alert.

I tried “Parent Group’s Message’s Attach1” but an issue showed up of "FileUploader Upload1: Attach this file to should be anything saveable but right now it is a file.

What am I supposed to attach the Upload to? Sorry for just not understanding this yet!

The important thing here is that the thing it gets attached to must exist before you upload the file., Right now it’s not the case.

1 Like

Hi Emmanuel,

That does make sense. Please let me know the correct procedure for this then; I know the whole point of Bubble is to figure it out but a shortcut would be much appreciated :smiley:

You should create the thing first, and then upload the file.

Hi Emmanuel,

I’ve tried that, as the attached shows. But the problem happens before the Send button (which initialises the creation of the message) is even pressed; as soon as a file is selected from the Uploader it fails and shows the “This is a private file, so please select an object to attach it to” alert. So how do I create a message before the User has pressed send?

Could you perhaps show me how to do it on the mcctestbed app I created? I’m apparently just not getting it and I don’t want to take any more of your time :slight_smile:

The upload isn’t done in the workflow, but at the element level. So you should have 2 workflows, one that creates and display the thing, and the other that uses the file uploader’s data.

that was my thought reading this, when a user starts to enter a message have a workflow create the thing with a not finished Yes/No operator so you have a simple constraint to pickup the near empty record from.

1 Like

Suggestion:
Probably a good I idea to add this to the help/ manual systems as followings:

Attach this file to
This option is only visible if ‘Make this file private’ is selected. Private files uploaded with this element are permanently attached to a thing, which is used to determine who has access to view the file. Only users who have the ‘View attached files’ permission for that thing can view the file. Go to the Privacy section to create privacy rules that grant this permission. If the value of ‘Attach this file to’ is empty or the thing does not exist, the file will be visible to anyone who has the link, which is the same as if ‘Make this file private’ was not selected.

To do this you will need a two step process. First create the record, using a workflow, where the field is contained. Then associate the containing element (eg. the group containing the File Uploader) in the record and upload the file using the File Uploader.

Sometime like this

3 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.