aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/shared/user-subscription/remote-subscribe.component.ts15
-rw-r--r--client/src/app/shared/user-subscription/subscribe-button.component.html4
-rw-r--r--client/src/app/shared/user-subscription/subscribe-button.component.ts14
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts6
-rw-r--r--server/controllers/static.ts13
6 files changed, 33 insertions, 21 deletions
diff --git a/client/src/app/shared/user-subscription/remote-subscribe.component.ts b/client/src/app/shared/user-subscription/remote-subscribe.component.ts
index ba2a45df1..63e7cd5d9 100644
--- a/client/src/app/shared/user-subscription/remote-subscribe.component.ts
+++ b/client/src/app/shared/user-subscription/remote-subscribe.component.ts
@@ -11,7 +11,7 @@ import {
11 styleUrls: ['./remote-subscribe.component.scss'] 11 styleUrls: ['./remote-subscribe.component.scss']
12}) 12})
13export class RemoteSubscribeComponent extends FormReactive implements OnInit { 13export class RemoteSubscribeComponent extends FormReactive implements OnInit {
14 @Input() account: string 14 @Input() uri: string
15 @Input() interact = false 15 @Input() interact = false
16 @Input() showHelp = false 16 @Input() showHelp = false
17 17
@@ -42,19 +42,20 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
42 fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`) 42 fetch(`https://${hostname}/.well-known/webfinger?resource=acct:${username}@${hostname}`)
43 .then(response => response.json()) 43 .then(response => response.json())
44 .then(data => new Promise((resolve, reject) => { 44 .then(data => new Promise((resolve, reject) => {
45 console.log(data)
46
45 if (data && Array.isArray(data.links)) { 47 if (data && Array.isArray(data.links)) {
46 const link: { 48 const link: { template: string } = data.links.find((link: any) => {
47 template: string 49 return link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe'
48 } = data.links.find((link: any) => 50 })
49 link && typeof link.template === 'string' && link.rel === 'http://ostatus.org/schema/1.0/subscribe')
50 51
51 if (link && link.template.includes('{uri}')) { 52 if (link && link.template.includes('{uri}')) {
52 resolve(link.template.replace('{uri}', `acct:${this.account}`)) 53 resolve(link.template.replace('{uri}', encodeURIComponent(this.uri)))
53 } 54 }
54 } 55 }
55 reject() 56 reject()
56 })) 57 }))
57 .then(window.open) 58 .then(window.open)
58 .catch(() => window.open(`https://${hostname}/authorize_interaction?acct=${this.account}`)) 59 .catch(err => console.error(err))
59 } 60 }
60} 61}
diff --git a/client/src/app/shared/user-subscription/subscribe-button.component.html b/client/src/app/shared/user-subscription/subscribe-button.component.html
index dbf6a34f0..d32647b42 100644
--- a/client/src/app/shared/user-subscription/subscribe-button.component.html
+++ b/client/src/app/shared/user-subscription/subscribe-button.component.html
@@ -41,7 +41,7 @@
41 </button> 41 </button>
42 42
43 <button class="dropdown-item" i18n>Subscribe with a Mastodon account:</button> 43 <button class="dropdown-item" i18n>Subscribe with a Mastodon account:</button>
44 <my-remote-subscribe showHelp="true" account="{{ uriAccount }}"></my-remote-subscribe> 44 <my-remote-subscribe showHelp="true" [uri]="channelUri"></my-remote-subscribe>
45 45
46 <div class="dropdown-divider"></div> 46 <div class="dropdown-divider"></div>
47 47
@@ -50,4 +50,4 @@
50 50
51 </div> 51 </div>
52 </div> 52 </div>
53</div> \ No newline at end of file 53</div>
diff --git a/client/src/app/shared/user-subscription/subscribe-button.component.ts b/client/src/app/shared/user-subscription/subscribe-button.component.ts
index ef470ee44..25515f6ea 100644
--- a/client/src/app/shared/user-subscription/subscribe-button.component.ts
+++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts
@@ -28,19 +28,19 @@ export class SubscribeButtonComponent implements OnInit {
28 private videoService: VideoService 28 private videoService: VideoService
29 ) { } 29 ) { }
30 30
31 get uri () { 31 get channelHandle () {
32 return this.videoChannel.name + '@' + this.videoChannel.host 32 return this.videoChannel.name + '@' + this.videoChannel.host
33 } 33 }
34 34
35 get uriAccount () { 35 get channelUri () {
36 return this.videoChannel.ownerAccount.name + '@' + this.videoChannel.host 36 return this.videoChannel.url
37 } 37 }
38 38
39 ngOnInit () { 39 ngOnInit () {
40 if (this.isUserLoggedIn()) { 40 if (this.isUserLoggedIn()) {
41 this.userSubscriptionService.doesSubscriptionExist(this.uri) 41 this.userSubscriptionService.doesSubscriptionExist(this.channelHandle)
42 .subscribe( 42 .subscribe(
43 res => this.subscribed = res[this.uri], 43 res => this.subscribed = res[this.channelHandle],
44 44
45 err => this.notifier.error(err.message) 45 err => this.notifier.error(err.message)
46 ) 46 )
@@ -56,7 +56,7 @@ export class SubscribeButtonComponent implements OnInit {
56 } 56 }
57 57
58 localSubscribe () { 58 localSubscribe () {
59 this.userSubscriptionService.addSubscription(this.uri) 59 this.userSubscriptionService.addSubscription(this.channelHandle)
60 .subscribe( 60 .subscribe(
61 () => { 61 () => {
62 this.subscribed = true 62 this.subscribed = true
@@ -78,7 +78,7 @@ export class SubscribeButtonComponent implements OnInit {
78 } 78 }
79 79
80 localUnsubscribe () { 80 localUnsubscribe () {
81 this.userSubscriptionService.deleteSubscription(this.uri) 81 this.userSubscriptionService.deleteSubscription(this.channelHandle)
82 .subscribe( 82 .subscribe(
83 () => { 83 () => {
84 this.subscribed = false 84 this.subscribed = false
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
index d8a7a78c4..916f5d0ff 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
@@ -41,7 +41,7 @@
41 <span i18n> 41 <span i18n>
42 If you have an account on Mastodon or Pleroma, you can open it directly in their interface: 42 If you have an account on Mastodon or Pleroma, you can open it directly in their interface:
43 </span> 43 </span>
44 <my-remote-subscribe [interact]="true" [account]="getUrl()"></my-remote-subscribe> 44 <my-remote-subscribe [interact]="true" [uri]="getUri()"></my-remote-subscribe>
45 </div> 45 </div>
46 <div class="modal-footer inputs"> 46 <div class="modal-footer inputs">
47 <span i18n class="action-button action-button-cancel" role="button" (click)="hideVisitorModal()"> 47 <span i18n class="action-button action-button-cancel" role="button" (click)="hideVisitorModal()">
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
index fd85c28f2..ac1d02d94 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
@@ -8,7 +8,6 @@ import { User } from '../../../shared/users'
8import { Video } from '../../../shared/video/video.model' 8import { Video } from '../../../shared/video/video.model'
9import { VideoComment } from './video-comment.model' 9import { VideoComment } from './video-comment.model'
10import { VideoCommentService } from './video-comment.service' 10import { VideoCommentService } from './video-comment.service'
11import { I18n } from '@ngx-translate/i18n-polyfill'
12import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
13import { VideoCommentValidatorsService } from '@app/shared/forms/form-validators/video-comment-validators.service' 12import { VideoCommentValidatorsService } from '@app/shared/forms/form-validators/video-comment-validators.service'
14import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 13import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -40,8 +39,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
40 private videoCommentService: VideoCommentService, 39 private videoCommentService: VideoCommentService,
41 private authService: AuthService, 40 private authService: AuthService,
42 private modalService: NgbModal, 41 private modalService: NgbModal,
43 private router: Router, 42 private router: Router
44 private i18n: I18n
45 ) { 43 ) {
46 super() 44 super()
47 } 45 }
@@ -124,7 +122,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
124 return this.form.value['text'] 122 return this.form.value['text']
125 } 123 }
126 124
127 getUrl () { 125 getUri () {
128 return window.location.href 126 return window.location.href
129 } 127 }
130 128
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 05019fcc2..73951be2d 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -156,6 +156,19 @@ staticRouter.use('/.well-known/change-password',
156 } 156 }
157) 157)
158 158
159staticRouter.use('/.well-known/host-meta',
160 (_, res: express.Response) => {
161 res.type('application/xml');
162
163 const xml = '<?xml version="1.0" encoding="UTF-8"?>\n' +
164 '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">\n' +
165 ` <Link rel="lrdd" type="application/xrd+xml" template="${WEBSERVER.URL}/.well-known/webfinger?resource={uri}"/>\n` +
166 '</XRD>'
167
168 res.send(xml).end()
169 }
170)
171
159// --------------------------------------------------------------------------- 172// ---------------------------------------------------------------------------
160 173
161export { 174export {