Skip to content

Commit

Permalink
yeag
Browse files Browse the repository at this point in the history
  • Loading branch information
gabboman committed Feb 6, 2025
1 parent 34bc776 commit 54f64d5
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 133 deletions.
219 changes: 93 additions & 126 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions packages/backend/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,17 +906,18 @@ async function updateBlueskyProfile(agent: BskyAgent, user: Model<any, any>) {
profile.avatar = avatarData
await fs.unlink(pngAvatar)
}
// TODO fix this
// TODO fix this it does not work
if (user.headerImage && false) {
let pngHeader = await optimizeMedia('uploads/' + user.headerImage, {
forceImageExtension: 'png',
let jpegHeader = await optimizeMedia('uploads/' + user.headerImage, {
forceImageExtension: 'jpg',
maxSize: 256,
keep: true
})
const userHeaderFile = Buffer.from(pngHeader)
const headerUpload = await agent.uploadBlob(userHeaderFile, { encoding: 'image/png' })
const userHeaderFile = Buffer.from(jpegHeader)
const headerUpload = await agent.uploadBlob(userHeaderFile, { encoding: 'image/jpeg' })
const headerData = headerUpload.data.blob
profile.banner = headerData
await fs.unlink(userHeaderFile)
}
}
return profile
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"private": true,
"dependencies": {
"@angular-eslint/schematics": "^19.0.2",
"@angular/animations": "^19.0.0",
"@angular/cdk": "^19.0.0",
"@angular/common": "^19.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<mat-card class="wafrn-container post-card">
<h1>Enable bluesky</h1>
<p>Read this! There is some jank still!</p>
<ul>
<li>Only posts marked as <b>public</b> will go to bluesky</li>
<li>
Notifications on bluesky SOMETIMES can be janky. Not seeing a follower on wafrn doesnt mean the follower does not
exist.
</li>
<li>By default, <b>all bluesky posts are public</b> wich means there is no unlisted post</li>
<li><b>Bluesky automaticaly accepts all follows by default</b>. Its different from fedi</li>
<li>Its owned by a corporation and they may not be your jam. We do the best to protect your</li>
<li>
Bluesky blocks are public by default. We are still not federating them, but we will add the option to make your
blocks on bluesky public in the future
</li>
<li>
Some posts may be marked as "only people i follow can reply" and stuff like that. Some jank we havent finished
</li>
<li>Like on fedi, not every post of every account gets saved in wafrn. We only save as much as we need</li>
<li>There is jank</li>
<li>There is jank and we are on it</li>
<li>There is A LOT OF JANK and we are on it</li>
<li>At the moment of writing this, your header image may not federate with bluesky still :(</li>
</ul>
<button [disabled]="loading" (click)="enableBluesky()" mat-flat-button class="w-full">Enable bluesky</button>
</mat-card>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { EnableBlueskyComponent } from './enable-bluesky.component';

describe('EnableBlueskyComponent', () => {
let component: EnableBlueskyComponent;
let fixture: ComponentFixture<EnableBlueskyComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [EnableBlueskyComponent]
})
.compileComponents();

fixture = TestBed.createComponent(EnableBlueskyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component } from '@angular/core'
import { MatButtonModule } from '@angular/material/button'
import { MatCardModule } from '@angular/material/card'
import { LoginService } from 'src/app/services/login.service'
@Component({
selector: 'app-enable-bluesky',
imports: [MatCardModule, MatButtonModule],
templateUrl: './enable-bluesky.component.html',
styleUrl: './enable-bluesky.component.scss'
})
export class EnableBlueskyComponent {
loading = false
constructor(private loginService: LoginService) {}

enableBluesky() {
this.loading = true
this.loginService.enableBluesky().then(() => {
this.loading = false
})
}
}
5 changes: 5 additions & 0 deletions packages/frontend/src/app/pages/profile/profile.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import { MyServerBlocksComponent } from './my-server-blocks/my-server-blocks.com
{
path: 'myAsks',
loadComponent: () => import('../ask-list/ask-list.component').then((c) => c.AskListComponent)
},
{
path: 'enable-bluesky',
loadComponent: () =>
import('../../pages/enable-bluesky/enable-bluesky.component').then((c) => c.EnableBlueskyComponent)
}
])
]
Expand Down
20 changes: 18 additions & 2 deletions packages/frontend/src/app/services/login.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { EventEmitter, Injectable } from '@angular/core'
import { Router } from '@angular/router'
import { HttpClient } from '@angular/common/http'
import { HttpClient, HttpErrorResponse } from '@angular/common/http'
import { UntypedFormGroup } from '@angular/forms'

import { UtilsService } from './utils.service'
import { JwtService } from './jwt.service'
import { PostsService } from './posts.service'
import { firstValueFrom } from 'rxjs'
import { EnvironmentService } from './environment.service'
import { MessageService } from './message.service'

@Injectable({
providedIn: 'root'
Expand All @@ -19,7 +20,8 @@ export class LoginService {
private router: Router,
private utils: UtilsService,
private jwt: JwtService,
private postsService: PostsService
private postsService: PostsService,
private messagesService: MessageService
) {}

checkUserLoggedIn(): boolean {
Expand Down Expand Up @@ -177,6 +179,20 @@ export class LoginService {
return success
}

async enableBluesky() {
try {
let result = await firstValueFrom(this.http.post(`${EnvironmentService.environment.baseUrl}/enable-bluesky`, {}))
this.messagesService.add({ severity: 'success', summary: 'Bluesky is enabled for you!' })
} catch (error: any) {
const tmp = error as HttpErrorResponse
this.messagesService.add({
severity: 'error',
summary: tmp.error.message ?? 'There was an error, try again or contact an administrator'
})
}
return
}

getLoggedUserUUID(): string {
const res = this.jwt.getTokenData().userId
return res ? res : ''
Expand Down

0 comments on commit 54f64d5

Please sign in to comment.