kopia lustrzana https://codeberg.org/nmkj/audon
fix avatar issue again
rodzic
26ec5e7086
commit
ea2a771349
|
@ -88,10 +88,10 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async joining(indicator) {
|
async joining(indicator) {
|
||||||
try {
|
try {
|
||||||
|
this.donStore.avatar = this.roomToken.original;
|
||||||
await this.roomClient.startAudio();
|
await this.roomClient.startAudio();
|
||||||
if (indicator && this.uploadEnabled) {
|
if (indicator && this.uploadEnabled) {
|
||||||
this.uploading = true;
|
this.uploading = true;
|
||||||
this.donStore.avatar = this.roomToken.original;
|
|
||||||
try {
|
try {
|
||||||
await this.donStore.updateAvatar(this.roomToken.indicator);
|
await this.donStore.updateAvatar(this.roomToken.indicator);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -79,3 +79,4 @@ closeRoomConfirm: "Are you sure you want to close this room?"
|
||||||
roomEvent:
|
roomEvent:
|
||||||
closedByHost: "Host has closed this room."
|
closedByHost: "Host has closed this room."
|
||||||
removed: "You have been requested to leave."
|
removed: "You have been requested to leave."
|
||||||
|
disconnected: "Disconnected from this room."
|
||||||
|
|
|
@ -78,4 +78,5 @@ microphoneBlocked: "マイクが禁止されています。ブラウザやデバ
|
||||||
closeRoomConfirm: "この部屋を閉じますか?"
|
closeRoomConfirm: "この部屋を閉じますか?"
|
||||||
roomEvent:
|
roomEvent:
|
||||||
closedByHost: "ホストにより部屋が閉じられました。"
|
closedByHost: "ホストにより部屋が閉じられました。"
|
||||||
removed: "部屋から退去しました。"
|
removed: "リクエストにより部屋から退去しました。"
|
||||||
|
disconneced: "切断されました。"
|
||||||
|
|
|
@ -48,10 +48,12 @@ export const useMastodonStore = defineStore("mastodon", {
|
||||||
},
|
},
|
||||||
async revertAvatar() {
|
async revertAvatar() {
|
||||||
const token = await axios.get("/api/token");
|
const token = await axios.get("/api/token");
|
||||||
if (this.avatar && token.data.audon.avatar) {
|
if (token.data.audon.avatar) {
|
||||||
await this.updateAvatar(this.avatar, token.data.audon.avatar);
|
if (this.avatar) {
|
||||||
};
|
await this.updateAvatar(this.avatar, token.data.audon.avatar);
|
||||||
await axios.delete("/api/room");
|
}
|
||||||
|
await axios.delete("/api/room");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -300,6 +300,14 @@ export default {
|
||||||
.on(RoomEvent.Disconnected, async (reason) => {
|
.on(RoomEvent.Disconnected, async (reason) => {
|
||||||
// TODO: change this from alert to a vuetify thing
|
// TODO: change this from alert to a vuetify thing
|
||||||
self.noSleep.disable();
|
self.noSleep.disable();
|
||||||
|
self.closeLoading = true;
|
||||||
|
try {
|
||||||
|
await self.donStore.revertAvatar();
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
self.closeLoading = false;
|
||||||
|
}
|
||||||
if (reason === DisconnectReason.PARTICIPANT_REMOVED) {
|
if (reason === DisconnectReason.PARTICIPANT_REMOVED) {
|
||||||
alert(self.$t("roomEvent.removed"));
|
alert(self.$t("roomEvent.removed"));
|
||||||
self.$router.push({ name: "home" });
|
self.$router.push({ name: "home" });
|
||||||
|
@ -307,32 +315,12 @@ export default {
|
||||||
let message = "";
|
let message = "";
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case DisconnectReason.ROOM_DELETED:
|
case DisconnectReason.ROOM_DELETED:
|
||||||
if (self.iamHost || self.iamCohost) {
|
|
||||||
self.closeLoading = true;
|
|
||||||
try {
|
|
||||||
await self.donStore.revertAvatar();
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
self.closeLoading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
message = self.$t("roomEvent.closedByHost");
|
message = self.$t("roomEvent.closedByHost");
|
||||||
break;
|
break;
|
||||||
case DisconnectReason.CLIENT_INITIATED:
|
case DisconnectReason.CLIENT_INITIATED:
|
||||||
if (self.iamCohost) {
|
|
||||||
self.closeLoading = true;
|
|
||||||
try {
|
|
||||||
await self.donStore.revertAvatar();
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
self.closeLoading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
message = "Disconnected due to unknown reasons";
|
message = self.$t("roomEvent.disconnected");
|
||||||
}
|
}
|
||||||
if (message !== "") {
|
if (message !== "") {
|
||||||
alert(message);
|
alert(message);
|
||||||
|
@ -625,13 +613,11 @@ export default {
|
||||||
async onRoomClose() {
|
async onRoomClose() {
|
||||||
// TODO: change this from confirm to a vuetify thing
|
// TODO: change this from confirm to a vuetify thing
|
||||||
if (confirm(this.$t("closeRoomConfirm"))) {
|
if (confirm(this.$t("closeRoomConfirm"))) {
|
||||||
this.loading = true;
|
this.closeLoading = true;
|
||||||
try {
|
try {
|
||||||
await axios.delete(`/api/room/${this.roomID}`);
|
await axios.delete(`/api/room/${this.roomID}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error);
|
alert(error);
|
||||||
} finally {
|
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
10
avatar.go
10
avatar.go
|
@ -33,7 +33,6 @@ func (u *AudonUser) GetIndicator(ctx context.Context, fnew []byte) ([]byte, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
hash := sha256.Sum256(fnew)
|
hash := sha256.Sum256(fnew)
|
||||||
isAvatarNew := false
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ func (u *AudonUser) GetIndicator(ctx context.Context, fnew []byte) ([]byte, erro
|
||||||
if err := os.WriteFile(saved, fnew, 0664); err != nil {
|
if err := os.WriteFile(saved, fnew, 0664); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
isAvatarNew = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fname := filepath.Base(saved)
|
fname := filepath.Base(saved)
|
||||||
|
@ -60,13 +58,7 @@ func (u *AudonUser) GetIndicator(ctx context.Context, fnew []byte) ([]byte, erro
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isAvatarNew {
|
buf := bytes.NewReader(fnew)
|
||||||
if data, err := os.ReadFile(u.GetOriginalAvatarPath(hash, mtype)); err == nil {
|
|
||||||
return data, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := bytes.NewBuffer(fnew)
|
|
||||||
|
|
||||||
var newImg image.Image
|
var newImg image.Image
|
||||||
if mtype.Is("image/png") {
|
if mtype.Is("image/png") {
|
||||||
|
|
9
room.go
9
room.go
|
@ -234,15 +234,6 @@ func joinRoomHandler(c echo.Context) (err error) {
|
||||||
return ErrRoomNotFound
|
return ErrRoomNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove old connection if user is already in the room
|
|
||||||
if room.IsUserInLivekitRoom(c.Request().Context(), user.AudonID) {
|
|
||||||
lkRoomServiceClient.RemoveParticipant(c.Request().Context(), &livekit.RoomParticipantIdentity{
|
|
||||||
Room: room.RoomID,
|
|
||||||
Identity: user.AudonID,
|
|
||||||
})
|
|
||||||
// return echo.NewHTTPError(http.StatusNotAcceptable, "already_in_room")
|
|
||||||
}
|
|
||||||
|
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
|
|
||||||
// check if room is not yet started
|
// check if room is not yet started
|
||||||
|
|
|
@ -98,7 +98,6 @@ func livekitWebhookHandler(c echo.Context) error {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
return c.NoContent(http.StatusOK)
|
|
||||||
} else if event.GetEvent() == webhook.EventRoomStarted {
|
} else if event.GetEvent() == webhook.EventRoomStarted {
|
||||||
// Have the bot advertise the room
|
// Have the bot advertise the room
|
||||||
room, err := findRoomByID(c.Request().Context(), event.GetRoom().GetName())
|
room, err := findRoomByID(c.Request().Context(), event.GetRoom().GetName())
|
||||||
|
|
Ładowanie…
Reference in New Issue