Skip to content

Conversation

@blizzz
Copy link
Member

@blizzz blizzz commented Oct 13, 2016

contributes to #753, items 2 and 4.

comment flow

  1. Write a comment with a mentions

1-create

  1. After saving, the rendered comment will show the displayname

2-done

  1. Oops! You forgot to mention someone else! Editing the comment will show the uids

3-edit

  1. When the edit is done, the comment is rendered with display names again

4-done

Tech background

In the back, the DAV endpoint will send mention information with the raw message.

spectacle f10473

The client (web ui here) replaces the uid with the displayname for presentation.

The next step (follow-up PR) will introduce autocomplete. After typing @ a search within the recipients of this file is supposed to happen. The client would make sure that the raw user id stays in the message, but its editing/composing abilities would hide this from the end user. That's the idea at least.

Todos left

  • evaluate JS tests (adjust, add, or neither?)

@mention-bot
Copy link

@blizzz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rullzer, @nickvergessen and @LukasReschke to be potential reviewers.

@nickvergessen
Copy link
Member

This is on "rendering" the comment?

@blizzz
Copy link
Member Author

blizzz commented Oct 16, 2016

This is on "rendering" the comment?

Yes, essentially 2. and 4. from #753. 2 alone without 4 is too cumbersome as it would introduce too much client business logic that then would be worthless when doing 4.

// exclude author, no self-mentioning
if($uid === '@' . $this->getActorId()) {
continue;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we plan only to support mentioning users. In the back of the head, mentioning groups in future might be reasonable. Thus we add a "type" key, however I am uncertain how we would implement this. Then there is a question whether a custom app would want to notify other, custom things. Is this legitimate? We could do this by extending the pattern and perhaps prepend a type between @ and the identifier (and defaulting to users). Just as food for thought.

@blizzz blizzz force-pushed the comments-provide-displaynames-with-mentions branch 2 times, most recently from 95fa09c to 9d97c7f Compare October 17, 2016 12:08
@blizzz blizzz changed the base branch from comments-user-mention to master October 17, 2016 12:08
@blizzz blizzz changed the title [WIP] comment mentions: show displayname not uid comment mentions: show displayname not uid Oct 17, 2016
@blizzz
Copy link
Member Author

blizzz commented Oct 17, 2016

Unsure about JS tests yet, thus still developing, otherwise I am happy about feedback – what do you think? @nickvergessen @rullzer @MorrisJobke (and anyone else is welcome, too :) )

@blizzz blizzz mentioned this pull request Oct 17, 2016
7 tasks
'objectId': '{' + NS_OWNCLOUD + '}objectId',
'isUnread': '{' + NS_OWNCLOUD + '}isUnread'
'isUnread': '{' + NS_OWNCLOUD + '}isUnread',
'mentions': '{' + NS_OWNCLOUD + '}mentions'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we start our namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we pointed out once we stay with the current namespaces.

for(var i in mentions) {
var mention = '@' + mentions[i].mentionId;
mention = mention.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
var displayName = '<b>'+ _.escape(mentions[i].mentionDisplayName)+'</b>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strong instead of b?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add avatar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nextcloud/designers wishes how it shoud look like?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I should use in the activity app and I guess it's the same everywhere: https://github.com/nextcloud/activity/blob/master/js/formatter.js#L145-L148

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented


for(var i in mentions) {
var mention = '@' + mentions[i].mentionId;
mention = mention.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mention a user test and testname this breaks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there… but it is impossible to parse everything properly.

Example:
"Let's talk about it today, @foobar."

Since we allow dots, @foobar and @foobar. are possible scenarios here. If you have both? Would be silly to insert a space between the username and the fullstop.

But even better it is that we allow white spaces in usernames now:

"@alice Bernadette wants to talk"

Username can be '@Alice Bernadette``or'@Alice``(or both).

For now, I improve the Regexp to have the 98% solution, butt when going with autocomplete I am afraid we need to wrap the mention into brackets to be able to support all these funny usernames.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

98% sounds good enough

const PROPERTY_NAME_MENTION = '{http://owncloud.org/ns}mention';
const PROPERTY_NAME_MENTION_TYPE = '{http://owncloud.org/ns}mentionType';
const PROPERTY_NAME_MENTION_ID = '{http://owncloud.org/ns}mentionId';
const PROPERTY_NAME_MENTION_DISPLAYNAME = '{http://owncloud.org/ns}mentionDisplayName';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextcloud? or too confusing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in #1738 (comment) and yes, it would increase confusion.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the comments-provide-displaynames-with-mentions branch from d3b891d to 1854339 Compare October 18, 2016 22:34
@nickvergessen
Copy link
Member

While posting the avatars are not loaded. Switching the sidebar tab and causing a reload fixes it. I assume there is just a JS call missing.
files_-nextcloud-_2016-10-19_09 39 55

@nickvergessen
Copy link
Member

Clicking on the edit button breaks things heavily:
files_-nextcloud-_2016-10-19_09 42 21

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
…ents

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the comments-provide-displaynames-with-mentions branch from 7d07922 to b12b52b Compare October 25, 2016 16:34
@blizzz blizzz added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 25, 2016
@blizzz
Copy link
Member Author

blizzz commented Oct 25, 2016

Review time 🎉

@codecov-io
Copy link

Current coverage is 57.91% (diff: 71.23%)

Sunburst

Diff Coverage File Path
0% apps/comments/appinfo/app.php
•••• 45% apps/dav/lib/Comments/CommentNode.php
•••••••••• 100% apps/comments/lib/Notification/Listener.php
•••••••••• 100% lib/private/Comments/Manager.php
•••••••••• 100% ...ps/comments/tests/Unit/Notification/ListenerTest.php
•••••••••• 100% lib/private/Comments/Comment.php

No coverage report found for master at 097a9ec.

Powered by Codecov. Last update 097a9ec...b12b52b

@nickvergessen
Copy link
Member

Works now, I will fix activities to also show the user names and avatars in a second PR

👍

@MorrisJobke
Copy link
Member

Tested and works 👍

@MorrisJobke MorrisJobke merged commit cde7f53 into master Oct 26, 2016
@MorrisJobke MorrisJobke deleted the comments-provide-displaynames-with-mentions branch October 26, 2016 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants